int shmcache_msgpack_unpack(char *content, size_t len, zval *rv) { ZVAL_NULL(rv); msgpack_unserialize_func(rv, content, len); return 0; }
/* {{{ timezone_process_timezone_argument * TimeZone argument processor. outside_error may be NULL (for static functions/constructors) */ U_CFUNC TimeZone *timezone_process_timezone_argument(zval *zv_timezone, intl_error *outside_error, const char *func) { zval local_zv_tz; char *message = NULL; TimeZone *timeZone; if (zv_timezone == NULL || Z_TYPE_P(zv_timezone) == IS_NULL) { timelib_tzinfo *tzinfo = get_timezone_info(); ZVAL_STRING(&local_zv_tz, tzinfo->name); zv_timezone = &local_zv_tz; } else { ZVAL_NULL(&local_zv_tz); } if (Z_TYPE_P(zv_timezone) == IS_OBJECT && instanceof_function(Z_OBJCE_P(zv_timezone), TimeZone_ce_ptr)) { TimeZone_object *to = Z_INTL_TIMEZONE_P(zv_timezone); if (to->utimezone == NULL) { spprintf(&message, 0, "%s: passed IntlTimeZone is not " "properly constructed", func); if (message) { intl_errors_set(outside_error, U_ILLEGAL_ARGUMENT_ERROR, message, 1); efree(message); } zval_dtor(&local_zv_tz); return NULL; } timeZone = to->utimezone->clone(); if (timeZone == NULL) { spprintf(&message, 0, "%s: could not clone TimeZone", func); if (message) { intl_errors_set(outside_error, U_MEMORY_ALLOCATION_ERROR, message, 1); efree(message); } zval_dtor(&local_zv_tz); return NULL; } } else if (Z_TYPE_P(zv_timezone) == IS_OBJECT && instanceof_function(Z_OBJCE_P(zv_timezone), php_date_get_timezone_ce())) { php_timezone_obj *tzobj = Z_PHPTIMEZONE_P(zv_timezone); zval_dtor(&local_zv_tz); return timezone_convert_datetimezone(tzobj->type, tzobj, 0, outside_error, func); } else { UnicodeString id, gottenId; UErrorCode status = U_ZERO_ERROR; /* outside_error may be NULL */ convert_to_string_ex(zv_timezone); if (intl_stringFromChar(id, Z_STRVAL_P(zv_timezone), Z_STRLEN_P(zv_timezone), &status) == FAILURE) { spprintf(&message, 0, "%s: Time zone identifier given is not a " "valid UTF-8 string", func); if (message) { intl_errors_set(outside_error, status, message, 1); efree(message); } zval_dtor(&local_zv_tz); return NULL; } timeZone = TimeZone::createTimeZone(id); if (timeZone == NULL) { spprintf(&message, 0, "%s: could not create time zone", func); if (message) { intl_errors_set(outside_error, U_MEMORY_ALLOCATION_ERROR, message, 1); efree(message); } zval_dtor(&local_zv_tz); return NULL; } if (timeZone->getID(gottenId) != id) { spprintf(&message, 0, "%s: no such time zone: '%s'", func, Z_STRVAL_P(zv_timezone)); if (message) { intl_errors_set(outside_error, U_ILLEGAL_ARGUMENT_ERROR, message, 1); efree(message); } zval_dtor(&local_zv_tz); delete timeZone; return NULL; } } zval_dtor(&local_zv_tz); return timeZone; }
/** * Returns an array of Phalcon\Db\Column objects describing a table * * <code>print_r($connection->describeColumns("posts")); ?></code> */ PHP_METHOD(Phalcon_Db_Adapter_Pdo_Oracle, describeColumns) { HashTable *_5; HashPosition _4; zephir_fcall_cache_entry *_24 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *table_param = NULL, *schema_param = NULL, *columns = NULL, *oldColumn = NULL, *field = NULL, *definition = NULL, *columnSize = NULL, *columnPrecision = NULL, *columnScale = NULL, *columnType = NULL, *columnName = NULL, *_0 = NULL, *_1, *_2 = NULL, *_3, **_6, *_7$$5 = NULL, *_8$$5 = NULL, *_9$$6 = NULL, *_10$$6 = NULL, *_11$$7 = NULL, *_12$$8 = NULL, *_13$$8 = NULL, *_14$$9 = NULL, *_15$$10 = NULL, *_16$$11 = NULL, *_17$$12 = NULL, *_18$$13 = NULL, *_19$$14 = NULL, *_20$$4 = NULL, *_21$$3, *_22$$3, *_23$$3 = NULL; zval *table = NULL, *schema = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table_param, &schema_param); if (unlikely(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(table_param) == IS_STRING)) { zephir_get_strval(table, table_param); } else { ZEPHIR_INIT_VAR(table); ZVAL_EMPTY_STRING(table); } if (!schema_param) { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } else { zephir_get_strval(schema, schema_param); } ZEPHIR_INIT_VAR(columns); array_init(columns); ZEPHIR_INIT_VAR(oldColumn); ZVAL_NULL(oldColumn); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_2, _1, "describecolumns", NULL, 0, table, schema); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, 3); ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchall", NULL, 0, _2, _3); zephir_check_call_status(); zephir_is_iterable(_0, &_5, &_4, 0, 0, "phalcon/db/adapter/pdo/oracle.zep", 208); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HVALUE(field, _6); ZEPHIR_INIT_NVAR(definition); zephir_create_array(definition, 1, 0 TSRMLS_CC); add_assoc_long_ex(definition, SS("bindType"), 2); ZEPHIR_OBS_NVAR(columnSize); zephir_array_fetch_long(&columnSize, field, 2, PH_NOISY, "phalcon/db/adapter/pdo/oracle.zep", 102 TSRMLS_CC); ZEPHIR_OBS_NVAR(columnPrecision); zephir_array_fetch_long(&columnPrecision, field, 3, PH_NOISY, "phalcon/db/adapter/pdo/oracle.zep", 103 TSRMLS_CC); ZEPHIR_OBS_NVAR(columnScale); zephir_array_fetch_long(&columnScale, field, 4, PH_NOISY, "phalcon/db/adapter/pdo/oracle.zep", 104 TSRMLS_CC); ZEPHIR_OBS_NVAR(columnType); zephir_array_fetch_long(&columnType, field, 1, PH_NOISY, "phalcon/db/adapter/pdo/oracle.zep", 105 TSRMLS_CC); while (1) { if (zephir_memnstr_str(columnType, SL("NUMBER"), "phalcon/db/adapter/pdo/oracle.zep", 112)) { ZEPHIR_INIT_NVAR(_7$$5); ZVAL_LONG(_7$$5, 3); zephir_array_update_string(&definition, SL("type"), &_7$$5, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &columnPrecision, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("scale"), &columnScale, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8$$5); ZVAL_LONG(_8$$5, 32); zephir_array_update_string(&definition, SL("bindType"), &_8$$5, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("INTEGER"), "phalcon/db/adapter/pdo/oracle.zep", 121)) { ZEPHIR_INIT_NVAR(_9$$6); ZVAL_LONG(_9$$6, 0); zephir_array_update_string(&definition, SL("type"), &_9$$6, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &columnPrecision, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_10$$6); ZVAL_LONG(_10$$6, 1); zephir_array_update_string(&definition, SL("bindType"), &_10$$6, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("VARCHAR2"), "phalcon/db/adapter/pdo/oracle.zep", 129)) { ZEPHIR_INIT_NVAR(_11$$7); ZVAL_LONG(_11$$7, 2); zephir_array_update_string(&definition, SL("type"), &_11$$7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &columnSize, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("FLOAT"), "phalcon/db/adapter/pdo/oracle.zep", 135)) { ZEPHIR_INIT_NVAR(_12$$8); ZVAL_LONG(_12$$8, 7); zephir_array_update_string(&definition, SL("type"), &_12$$8, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &columnSize, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("scale"), &columnScale, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_13$$8); ZVAL_LONG(_13$$8, 32); zephir_array_update_string(&definition, SL("bindType"), &_13$$8, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("TIMESTAMP"), "phalcon/db/adapter/pdo/oracle.zep", 144)) { ZEPHIR_INIT_NVAR(_14$$9); ZVAL_LONG(_14$$9, 17); zephir_array_update_string(&definition, SL("type"), &_14$$9, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("DATE"), "phalcon/db/adapter/pdo/oracle.zep", 149)) { ZEPHIR_INIT_NVAR(_15$$10); ZVAL_LONG(_15$$10, 1); zephir_array_update_string(&definition, SL("type"), &_15$$10, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("RAW"), "phalcon/db/adapter/pdo/oracle.zep", 154)) { ZEPHIR_INIT_NVAR(_16$$11); ZVAL_LONG(_16$$11, 6); zephir_array_update_string(&definition, SL("type"), &_16$$11, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("BLOB"), "phalcon/db/adapter/pdo/oracle.zep", 159)) { ZEPHIR_INIT_NVAR(_17$$12); ZVAL_LONG(_17$$12, 6); zephir_array_update_string(&definition, SL("type"), &_17$$12, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("CLOB"), "phalcon/db/adapter/pdo/oracle.zep", 164)) { ZEPHIR_INIT_NVAR(_18$$13); ZVAL_LONG(_18$$13, 6); zephir_array_update_string(&definition, SL("type"), &_18$$13, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("CHAR"), "phalcon/db/adapter/pdo/oracle.zep", 169)) { ZEPHIR_INIT_NVAR(_19$$14); ZVAL_LONG(_19$$14, 5); zephir_array_update_string(&definition, SL("type"), &_19$$14, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &columnSize, PH_COPY | PH_SEPARATE); break; } ZEPHIR_INIT_NVAR(_20$$4); ZVAL_LONG(_20$$4, 6); zephir_array_update_string(&definition, SL("type"), &_20$$4, PH_COPY | PH_SEPARATE); break; } if (Z_TYPE_P(oldColumn) == IS_NULL) { zephir_array_update_string(&definition, SL("first"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } else { zephir_array_update_string(&definition, SL("after"), &oldColumn, PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_21$$3, field, 6, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/oracle.zep", 188 TSRMLS_CC); if (ZEPHIR_IS_STRING(_21$$3, "P")) { zephir_array_update_string(&definition, SL("primary"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_22$$3, field, 5, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/oracle.zep", 195 TSRMLS_CC); if (ZEPHIR_IS_STRING(_22$$3, "N")) { zephir_array_update_string(&definition, SL("notNull"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&columnName, field, 0, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/oracle.zep", 199 TSRMLS_CC); ZEPHIR_INIT_NVAR(_23$$3); object_init_ex(_23$$3, phalcon_db_column_ce); ZEPHIR_CALL_METHOD(NULL, _23$$3, "__construct", &_24, 137, columnName, definition); zephir_check_call_status(); zephir_array_append(&columns, _23$$3, PH_SEPARATE, "phalcon/db/adapter/pdo/oracle.zep", 204); ZEPHIR_CPY_WRT(oldColumn, columnName); } RETURN_CCTOR(columns); }
/* {{{ php_oci_collection_element_get() Get the element with the given index */ int php_oci_collection_element_get(php_oci_collection *collection, zend_long index, zval *result_element) { php_oci_connection *connection = collection->connection; dvoid *element; OCIInd *element_index; boolean exists; oratext buff[1024]; ub4 buff_len = 1024; sword errstatus; ZVAL_NULL(result_element); connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ PHP_OCI_CALL_RETURN(errstatus, OCICollGetElem, ( connection->env, connection->err, collection->collection, (ub4)index, &exists, &element, (dvoid **)&element_index ) ); if (errstatus != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, errstatus); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } if (exists == 0) { /* element doesn't exist */ return 1; } if (*element_index == OCI_IND_NULL) { /* this is not an error, we're returning NULL here */ return 0; } switch (collection->element_typecode) { case OCI_TYPECODE_DATE: PHP_OCI_CALL_RETURN(errstatus, OCIDateToText, (connection->err, element, 0, 0, 0, 0, &buff_len, buff)); if (errstatus != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, errstatus); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } ZVAL_STRINGL(result_element, (char *)buff, buff_len); Z_STRVAL_P(result_element)[buff_len] = '\0'; return 0; break; case OCI_TYPECODE_VARCHAR2: { OCIString *oci_string = *(OCIString **)element; text *str; PHP_OCI_CALL_RETURN(str, OCIStringPtr, (connection->env, oci_string)); if (str) { ZVAL_STRING(result_element, (char *)str); } return 0; } break; case OCI_TYPECODE_UNSIGNED16: /* UNSIGNED SHORT */ case OCI_TYPECODE_UNSIGNED32: /* UNSIGNED LONG */ case OCI_TYPECODE_REAL: /* REAL */ case OCI_TYPECODE_DOUBLE: /* DOUBLE */ case OCI_TYPECODE_INTEGER: /* INT */ case OCI_TYPECODE_SIGNED16: /* SHORT */ case OCI_TYPECODE_SIGNED32: /* LONG */ case OCI_TYPECODE_DECIMAL: /* DECIMAL */ case OCI_TYPECODE_FLOAT: /* FLOAT */ case OCI_TYPECODE_NUMBER: /* NUMBER */ case OCI_TYPECODE_SMALLINT: /* SMALLINT */ { double double_number; PHP_OCI_CALL_RETURN(errstatus, OCINumberToReal, (connection->err, (CONST OCINumber *) element, (uword) sizeof(double), (dvoid *) &double_number)); if (errstatus != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, errstatus); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } ZVAL_DOUBLE(result_element, double_number); return 0; } break; default: php_error_docref(NULL, E_NOTICE, "Unknown or unsupported type of element: %d", collection->element_typecode); return 1; break; } /* never reached */ return 1; }
/** * Checks for annotations in the public methods of the controller * * @param string module * @param string namespaceName * @param string controller * @param string action * @param Phalcon\Annotations\Annotation annotation */ PHP_METHOD(Phalcon_Mvc_Router_Annotations, processActionAnnotation) { zephir_fcall_cache_entry *_7 = NULL, *_11 = NULL; HashTable *_5, *_9; HashPosition _4, _8; int ZEPHIR_LAST_CALL_STATUS; zend_bool isRoute; zval *module_param = NULL, *namespaceName_param = NULL, *controller_param = NULL, *action_param = NULL, *annotation, *name = NULL, *actionName, *routePrefix, *paths = NULL, *value = NULL, *uri = NULL, *route = NULL, *methods = NULL, *converts = NULL, *param = NULL, *convert = NULL, *conversorParam = NULL, *routeName = NULL, *_0, *_1, _2, *_3 = NULL, **_6, **_10; zval *module = NULL, *namespaceName = NULL, *controller = NULL, *action = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 5, 0, &module_param, &namespaceName_param, &controller_param, &action_param, &annotation); if (unlikely(Z_TYPE_P(module_param) != IS_STRING && Z_TYPE_P(module_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'module' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(module_param) == IS_STRING)) { zephir_get_strval(module, module_param); } else { ZEPHIR_INIT_VAR(module); ZVAL_EMPTY_STRING(module); } if (unlikely(Z_TYPE_P(namespaceName_param) != IS_STRING && Z_TYPE_P(namespaceName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'namespaceName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(namespaceName_param) == IS_STRING)) { zephir_get_strval(namespaceName, namespaceName_param); } else { ZEPHIR_INIT_VAR(namespaceName); ZVAL_EMPTY_STRING(namespaceName); } if (unlikely(Z_TYPE_P(controller_param) != IS_STRING && Z_TYPE_P(controller_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controller' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(controller_param) == IS_STRING)) { zephir_get_strval(controller, controller_param); } else { ZEPHIR_INIT_VAR(controller); ZVAL_EMPTY_STRING(controller); } if (unlikely(Z_TYPE_P(action_param) != IS_STRING && Z_TYPE_P(action_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'action' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(action_param) == IS_STRING)) { zephir_get_strval(action, action_param); } else { ZEPHIR_INIT_VAR(action); ZVAL_EMPTY_STRING(action); } isRoute = 0; ZEPHIR_INIT_VAR(methods); ZVAL_NULL(methods); ZEPHIR_CALL_METHOD(&name, annotation, "getname", NULL); zephir_check_call_status(); if (ZEPHIR_IS_STRING(name, "Route")) { isRoute = 1; } else { if (ZEPHIR_IS_STRING(name, "Get")) { isRoute = 1; ZEPHIR_INIT_NVAR(methods); ZVAL_STRING(methods, "GET", 1); } else { if (ZEPHIR_IS_STRING(name, "Post")) { isRoute = 1; ZEPHIR_INIT_NVAR(methods); ZVAL_STRING(methods, "POST", 1); } else { if (ZEPHIR_IS_STRING(name, "Put")) { isRoute = 1; ZEPHIR_INIT_NVAR(methods); ZVAL_STRING(methods, "PUT", 1); } else { if (ZEPHIR_IS_STRING(name, "Options")) { isRoute = 1; ZEPHIR_INIT_NVAR(methods); ZVAL_STRING(methods, "OPTIONS", 1); } } } } } if (isRoute == 1) { ZEPHIR_INIT_VAR(actionName); ZEPHIR_INIT_VAR(_0); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_actionSuffix"), PH_NOISY_CC); ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "", 0); zephir_fast_str_replace(&_0, _1, &_2, action TSRMLS_CC); zephir_fast_strtolower(actionName, _0); ZEPHIR_OBS_VAR(routePrefix); zephir_read_property_this(&routePrefix, this_ptr, SL("_routePrefix"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "paths", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&paths, annotation, "getnamedargument", NULL, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); if (Z_TYPE_P(paths) != IS_ARRAY) { ZEPHIR_INIT_NVAR(paths); array_init(paths); } if (!(ZEPHIR_IS_EMPTY(module))) { zephir_array_update_string(&paths, SL("module"), &module, PH_COPY | PH_SEPARATE); } if (!(ZEPHIR_IS_EMPTY(namespaceName))) { zephir_array_update_string(&paths, SL("namespace"), &namespaceName, PH_COPY | PH_SEPARATE); } zephir_array_update_string(&paths, SL("controller"), &controller, PH_COPY | PH_SEPARATE); zephir_array_update_string(&paths, SL("action"), &actionName, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, 0); ZEPHIR_CALL_METHOD(&value, annotation, "getargument", NULL, _3); zephir_check_call_status(); if (Z_TYPE_P(value) != IS_NULL) { if (!ZEPHIR_IS_STRING(value, "/")) { ZEPHIR_INIT_VAR(uri); ZEPHIR_CONCAT_VV(uri, routePrefix, value); } else { ZEPHIR_CPY_WRT(uri, routePrefix); } } else { ZEPHIR_INIT_NVAR(uri); ZEPHIR_CONCAT_VV(uri, routePrefix, actionName); } ZEPHIR_CALL_METHOD(&route, this_ptr, "add", NULL, uri, paths); zephir_check_call_status(); if (Z_TYPE_P(methods) != IS_NULL) { ZEPHIR_CALL_METHOD(NULL, route, "via", NULL, methods); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "methods", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&methods, annotation, "getnamedargument", NULL, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); if (Z_TYPE_P(methods) == IS_ARRAY) { ZEPHIR_CALL_METHOD(NULL, route, "via", NULL, methods); zephir_check_call_status(); } else { if (Z_TYPE_P(methods) == IS_STRING) { ZEPHIR_CALL_METHOD(NULL, route, "via", NULL, methods); zephir_check_call_status(); } } } ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "converts", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&converts, annotation, "getnamedargument", NULL, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); if (Z_TYPE_P(converts) == IS_ARRAY) { zephir_is_iterable(converts, &_5, &_4, 0, 0, "phalcon/mvc/router/annotations.zep", 348); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HMKEY(param, _5, _4); ZEPHIR_GET_HVALUE(convert, _6); ZEPHIR_CALL_METHOD(NULL, route, "convert", &_7, param, convert); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "conversors", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&converts, annotation, "getnamedargument", NULL, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); if (Z_TYPE_P(converts) == IS_ARRAY) { zephir_is_iterable(converts, &_9, &_8, 0, 0, "phalcon/mvc/router/annotations.zep", 358); for ( ; zephir_hash_get_current_data_ex(_9, (void**) &_10, &_8) == SUCCESS ; zephir_hash_move_forward_ex(_9, &_8) ) { ZEPHIR_GET_HMKEY(conversorParam, _9, _8); ZEPHIR_GET_HVALUE(convert, _10); ZEPHIR_CALL_METHOD(NULL, route, "convert", &_11, conversorParam, convert); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "name", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&routeName, annotation, "getnamedargument", NULL, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); if (Z_TYPE_P(routeName) == IS_STRING) { ZEPHIR_CALL_METHOD(NULL, route, "setname", NULL, routeName); zephir_check_call_status(); } RETURN_MM_BOOL(1); } ZEPHIR_MM_RESTORE(); }
/* {{{ version string readonly=no URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Entity3-version Since: DOM Level 3 */ int dom_entity_version_read(dom_object *obj, zval *retval) { ZVAL_NULL(retval); return SUCCESS; }
/** * Reads an item from an array using a zval as index */ int phalcon_array_fetch(zval **return_value, zval *arr, zval *index, int silent TSRMLS_DC) { zval **zv; int result = FAILURE, type; if (Z_TYPE_P(index) == IS_ARRAY || Z_TYPE_P(index) == IS_OBJECT) { ZVAL_NULL(*return_value); if (silent == PH_NOISY) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Illegal offset type"); } return FAILURE; } if (Z_TYPE_P(index) == IS_NULL) { convert_to_string(index); } ZVAL_NULL(*return_value); if (Z_TYPE_P(arr) == IS_NULL || Z_TYPE_P(arr) == IS_BOOL) { return FAILURE; } if (Z_TYPE_P(index) != IS_STRING && Z_TYPE_P(index) != IS_LONG && Z_TYPE_P(index) != IS_DOUBLE) { if (silent == PH_NOISY) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Illegal offset type"); } return FAILURE; } if (Z_TYPE_P(index) == IS_STRING) { if((type = is_numeric_string(Z_STRVAL_P(index), Z_STRLEN_P(index), NULL, NULL, 0))) { if (type == IS_LONG) { convert_to_long(index); } } } else { if (Z_TYPE_P(index) == IS_DOUBLE) { convert_to_long(index); } } if (Z_TYPE_P(index) == IS_STRING) { if((result = zend_hash_find(Z_ARRVAL_P(arr), Z_STRVAL_P(index), Z_STRLEN_P(index)+1, (void**) &zv)) == SUCCESS) { zval_ptr_dtor(return_value); *return_value = *zv; Z_ADDREF_PP(return_value); return SUCCESS; } } if (Z_TYPE_P(index) == IS_LONG) { if ((result = zend_hash_index_find(Z_ARRVAL_P(arr), Z_LVAL_P(index), (void**) &zv)) == SUCCESS) { zval_ptr_dtor(return_value); *return_value = *zv; Z_ADDREF_PP(return_value); return SUCCESS; } } if (silent == PH_NOISY) { if (Z_TYPE_P(index) == IS_LONG) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Undefined index: %ld", Z_LVAL_P(index)); } else { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Undefined index: %s", Z_STRVAL_P(index)); } } return FAILURE; }
static int do_callback(struct pdo_sqlite_fci *fc, zval *cb, int argc, sqlite3_value **argv, sqlite3_context *context, int is_agg) { zval *zargs = NULL; zval retval; int i; int ret; int fake_argc; zend_reference *agg_context = NULL; if (is_agg) { is_agg = 2; } fake_argc = argc + is_agg; fc->fci.size = sizeof(fc->fci); ZVAL_COPY_VALUE(&fc->fci.function_name, cb); fc->fci.object = NULL; fc->fci.retval = &retval; fc->fci.param_count = fake_argc; /* build up the params */ if (fake_argc) { zargs = safe_emalloc(fake_argc, sizeof(zval), 0); } if (is_agg) { agg_context = (zend_reference*)sqlite3_aggregate_context(context, sizeof(zend_reference)); if (!agg_context) { ZVAL_NULL(&zargs[0]); } else { if (Z_ISUNDEF(agg_context->val)) { GC_REFCOUNT(agg_context) = 1; GC_TYPE_INFO(agg_context) = IS_REFERENCE; ZVAL_NULL(&agg_context->val); } ZVAL_REF(&zargs[0], agg_context); } ZVAL_LONG(&zargs[1], sqlite3_aggregate_count(context)); } for (i = 0; i < argc; i++) { /* get the value */ switch (sqlite3_value_type(argv[i])) { case SQLITE_INTEGER: ZVAL_LONG(&zargs[i + is_agg], sqlite3_value_int(argv[i])); break; case SQLITE_FLOAT: ZVAL_DOUBLE(&zargs[i + is_agg], sqlite3_value_double(argv[i])); break; case SQLITE_NULL: ZVAL_NULL(&zargs[i + is_agg]); break; case SQLITE_BLOB: case SQLITE3_TEXT: default: ZVAL_STRINGL(&zargs[i + is_agg], (char*)sqlite3_value_text(argv[i]), sqlite3_value_bytes(argv[i])); break; } } fc->fci.params = zargs; if ((ret = zend_call_function(&fc->fci, &fc->fcc)) == FAILURE) { php_error_docref(NULL, E_WARNING, "An error occurred while invoking the callback"); } /* clean up the params */ if (zargs) { for (i = is_agg; i < fake_argc; i++) { zval_ptr_dtor(&zargs[i]); } if (is_agg) { zval_ptr_dtor(&zargs[1]); } efree(zargs); } if (!is_agg || !argv) { /* only set the sqlite return value if we are a scalar function, * or if we are finalizing an aggregate */ if (!Z_ISUNDEF(retval)) { switch (Z_TYPE(retval)) { case IS_LONG: sqlite3_result_int(context, Z_LVAL(retval)); break; case IS_NULL: sqlite3_result_null(context); break; case IS_DOUBLE: sqlite3_result_double(context, Z_DVAL(retval)); break; default: convert_to_string_ex(&retval); sqlite3_result_text(context, Z_STRVAL(retval), Z_STRLEN(retval), SQLITE_TRANSIENT); break; } } else { sqlite3_result_error(context, "failed to invoke callback", 0); } if (agg_context) { zval_ptr_dtor(&agg_context->val); } } else { /* we're stepping in an aggregate; the return value goes into * the context */ if (agg_context) { zval_ptr_dtor(&agg_context->val); } if (!Z_ISUNDEF(retval)) { ZVAL_COPY_VALUE(&agg_context->val, &retval); ZVAL_UNDEF(&retval); } else { ZVAL_UNDEF(&agg_context->val); } } if (!Z_ISUNDEF(retval)) { zval_ptr_dtor(&retval); } return ret; }
/** * Initialize the metadata for certain table */ PHP_METHOD(Phalcon_Mvc_Model_MetaData, _initialize) { zephir_fcall_cache_entry *_2 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *model, *key, *table, *schema, *strategy = NULL, *className, *metaData, *data = NULL, *modelMetadata = NULL, *modelColumnMap = NULL, *dependencyInjector = NULL, *keyName, *prefixKey = NULL, *_0, *_1, *_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &model, &key, &table, &schema); ZEPHIR_INIT_VAR(strategy); ZVAL_NULL(strategy); ZEPHIR_INIT_VAR(className); zephir_get_class(className, model, 0 TSRMLS_CC); if (Z_TYPE_P(key) != IS_NULL) { ZEPHIR_OBS_VAR(metaData); zephir_read_property_this(&metaData, this_ptr, SL("_metaData"), PH_NOISY_CC); if (!(zephir_array_isset(metaData, key))) { ZEPHIR_INIT_VAR(prefixKey); ZEPHIR_CONCAT_SV(prefixKey, "meta-", key); ZEPHIR_CALL_METHOD(&data, this_ptr, "read", NULL, 0, prefixKey); zephir_check_call_status(); if (Z_TYPE_P(data) != IS_NULL) { zephir_update_property_array(this_ptr, SL("_metaData"), key, data TSRMLS_CC); } else { if ((zephir_method_exists_ex(model, SS("metadata") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&modelMetadata, model, "metadata", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(modelMetadata) != IS_ARRAY) { ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SV(_1, "Invalid meta-data for model ", className); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _1); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/mvc/model/metadata.zep", 119 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } else { ZEPHIR_OBS_VAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&strategy, this_ptr, "getstrategy", &_2, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&modelMetadata, strategy, "getmetadata", NULL, 0, model, dependencyInjector); zephir_check_call_status(); } zephir_update_property_array(this_ptr, SL("_metaData"), key, modelMetadata TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", NULL, 0, prefixKey, modelMetadata); zephir_check_call_status(); } } } if (!(ZEPHIR_GLOBAL(orm).column_renaming)) { RETURN_MM_NULL(); } ZEPHIR_INIT_VAR(keyName); zephir_fast_strtolower(keyName, className); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_columnMap"), PH_NOISY_CC); if (zephir_array_isset(_3, keyName)) { RETURN_MM_NULL(); } ZEPHIR_INIT_NVAR(prefixKey); ZEPHIR_CONCAT_SV(prefixKey, "map-", keyName); ZEPHIR_CALL_METHOD(&data, this_ptr, "read", NULL, 0, prefixKey); zephir_check_call_status(); if (Z_TYPE_P(data) != IS_NULL) { zephir_update_property_array(this_ptr, SL("_columnMap"), keyName, data TSRMLS_CC); RETURN_MM_NULL(); } if (Z_TYPE_P(strategy) != IS_OBJECT) { ZEPHIR_OBS_NVAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&strategy, this_ptr, "getstrategy", &_2, 0); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&modelColumnMap, strategy, "getcolumnmaps", NULL, 0, model, dependencyInjector); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("_columnMap"), keyName, modelColumnMap TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", NULL, 0, prefixKey, modelColumnMap); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); }
PHP_METHOD(MongoGridFS, __construct) { zval *zdb, *files = 0, *chunks = 0, *zchunks; zval *z_w = NULL; /* chunks is deprecated */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|zz", &zdb, mongo_ce_DB, &files, &chunks) == FAILURE) { zval *object = getThis(); ZVAL_NULL(object); return; } if (!files && !chunks) { MAKE_STD_ZVAL(files); ZVAL_STRING(files, "fs.files", 1); MAKE_STD_ZVAL(chunks); ZVAL_STRING(chunks, "fs.chunks", 1); } else { zval *temp_file; char *temp; if (Z_TYPE_P(files) != IS_STRING || Z_STRLEN_P(files) == 0 ) { zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 2 TSRMLS_CC, "MongoGridFS::__construct(): invalid prefix"); return; } MAKE_STD_ZVAL(chunks); spprintf(&temp, 0, "%s.chunks", Z_STRVAL_P(files)); ZVAL_STRING(chunks, temp, 0); MAKE_STD_ZVAL(temp_file); spprintf(&temp, 0, "%s.files", Z_STRVAL_P(files)); ZVAL_STRING(temp_file, temp, 0); files = temp_file; } /* create files collection */ MONGO_METHOD2(MongoCollection, __construct, return_value, getThis(), zdb, files); /* create chunks collection */ MAKE_STD_ZVAL(zchunks); object_init_ex(zchunks, mongo_ce_Collection); MONGO_METHOD2(MongoCollection, __construct, return_value, zchunks, zdb, chunks); /* add chunks collection as a property */ zend_update_property(mongo_ce_GridFS, getThis(), "chunks", strlen("chunks"), zchunks TSRMLS_CC); zend_update_property(mongo_ce_GridFS, getThis(), "filesName", strlen("filesName"), files TSRMLS_CC); zend_update_property(mongo_ce_GridFS, getThis(), "chunksName", strlen("chunksName"), chunks TSRMLS_CC); /* GridFS is forced in our codebase to be w=1 so this property doesn't actually mean * anything, but we can't lie to the user so we have to overwrite it if the MongoDB * object that created this object was w=0. * This property is initialized in the MongoCollection (which we extend) ctor */ z_w = zend_read_property(mongo_ce_GridFS, getThis(), "w", strlen("w"), NOISY TSRMLS_CC); if (Z_TYPE_P(z_w) != IS_STRING) { convert_to_long(z_w); if (Z_LVAL_P(z_w) < 2) { zend_update_property_long(mongo_ce_GridFS, getThis(), "w", strlen("w"), 1 TSRMLS_CC); } } /* cleanup */ zval_ptr_dtor(&zchunks); zval_ptr_dtor(&files); zval_ptr_dtor(&chunks); }
void init_executor(void) /* {{{ */ { zend_init_fpu(); ZVAL_NULL(&EG(uninitialized_zval)); ZVAL_ERROR(&EG(error_zval)); /* destroys stack frame, therefore makes core dumps worthless */ #if 0&&ZEND_DEBUG original_sigsegv_handler = signal(SIGSEGV, zend_handle_sigsegv); #endif EG(symtable_cache_ptr) = EG(symtable_cache) - 1; EG(symtable_cache_limit) = EG(symtable_cache) + SYMTABLE_CACHE_SIZE - 1; EG(no_extensions) = 0; EG(function_table) = CG(function_table); EG(class_table) = CG(class_table); EG(in_autoload) = NULL; EG(autoload_func) = NULL; EG(error_handling) = EH_NORMAL; EG(flags) = EG_FLAGS_INITIAL; zend_vm_stack_init(); zend_hash_init(&EG(symbol_table), 64, NULL, ZVAL_PTR_DTOR, 0); zend_llist_apply(&zend_extensions, (llist_apply_func_t) zend_extension_activator); zend_hash_init(&EG(included_files), 8, NULL, NULL, 0); EG(ticks_count) = 0; ZVAL_UNDEF(&EG(user_error_handler)); ZVAL_UNDEF(&EG(user_exception_handler)); EG(current_execute_data) = NULL; zend_stack_init(&EG(user_error_handlers_error_reporting), sizeof(int)); zend_stack_init(&EG(user_error_handlers), sizeof(zval)); zend_stack_init(&EG(user_exception_handlers), sizeof(zval)); zend_objects_store_init(&EG(objects_store), 1024); EG(full_tables_cleanup) = 0; EG(vm_interrupt) = 0; EG(timed_out) = 0; EG(exception) = NULL; EG(prev_exception) = NULL; EG(fake_scope) = NULL; EG(ht_iterators_count) = sizeof(EG(ht_iterators_slots)) / sizeof(HashTableIterator); EG(ht_iterators_used) = 0; EG(ht_iterators) = EG(ht_iterators_slots); memset(EG(ht_iterators), 0, sizeof(EG(ht_iterators_slots))); EG(each_deprecation_thrown) = 0; EG(active) = 1; }
/** * Executes the validation */ PHP_METHOD(Phalcon_Validation_Validator_Regex, validate) { int ZEPHIR_LAST_CALL_STATUS; zend_bool failed, _2; zval *field = NULL; zval *validation, *field_param = NULL, *matches, *message = NULL, *value = NULL, *label = NULL, *replacePairs, *_0 = NULL, *_1 = NULL, *_3 = NULL, *_4 = NULL, *_5, *_6 = NULL, *_7; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_INIT_VAR(matches); ZVAL_NULL(matches); ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0, this_ptr, "issetoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); _2 = zephir_is_true(_0); if (_2) { _2 = ZEPHIR_IS_EMPTY(value); } if (_2) { RETURN_MM_BOOL(1); } ZEPHIR_INIT_NVAR(_1); ZEPHIR_INIT_VAR(_4); ZVAL_STRING(_4, "pattern", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_3, this_ptr, "getoption", NULL, 0, _4); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_preg_match(_1, _3, value, matches, 0, 0 , 0 TSRMLS_CC); if (zephir_is_true(_1)) { zephir_array_fetch_long(&_5, matches, 0, PH_NOISY | PH_READONLY, "phalcon/validation/validator/regex.zep", 62 TSRMLS_CC); failed = !ZEPHIR_IS_EQUAL(_5, value); } else { failed = 1; } if (failed == 1) { ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _4); zephir_check_temp_parameter(_4); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _4); zephir_check_temp_parameter(_4); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Regex", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _4); zephir_check_temp_parameter(_4); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_4); object_init_ex(_4, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_6, "strtr", NULL, 73, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_7); ZVAL_STRING(_7, "Regex", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _4, "__construct", NULL, 425, _6, field, _7); zephir_check_temp_parameter(_7); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _4); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); }
/** * Executes the validation */ PHP_METHOD(Phalcon_Validation_Validator_File, validate) { zend_bool _2, _3, _4, _6, _7, _16, _17, _19, _27, _28, _62, _69$$20, _78$$25; zephir_fcall_cache_entry *_12 = NULL, *_15 = NULL, *_41 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *_SERVER, *_POST, *_FILES, *value = NULL, *message = NULL, *label = NULL, *replacePairs = NULL, *types = NULL, *byteUnits = NULL, *unit = NULL, *maxSize = NULL, *matches = NULL, *bytes = NULL, *mime = NULL, *tmp = NULL, *width = NULL, *height = NULL, *minResolution = NULL, *maxResolution = NULL, *minWidth = NULL, *maxWidth = NULL, *minHeight = NULL, *maxHeight = NULL, *_0 = NULL, *_1, *_5, *_8, *_18, *_20, *_21 = NULL, *_34 = NULL, *_52 = NULL, *_61 = NULL, *_63 = NULL, *_9$$4 = NULL, *_11$$4 = NULL, *_13$$4 = NULL, *_14$$4 = NULL, *_10$$5, *_22$$6 = NULL, *_24$$6 = NULL, *_25$$6 = NULL, *_26$$6 = NULL, *_23$$7, *_29$$8 = NULL, *_31$$8 = NULL, *_32$$8 = NULL, *_33$$8 = NULL, *_30$$9, *_35$$10 = NULL, *_36$$10, *_37$$10, *_38$$10, *_39$$10, *_40$$10 = NULL, *_42$$10, *_43$$10, _44$$10, *_45$$10, *_46$$10 = NULL, *_47$$12 = NULL, *_49$$12 = NULL, *_50$$12 = NULL, *_51$$12 = NULL, *_48$$13, *_53$$14, _54$$16, *_55$$16, *_56$$18 = NULL, *_58$$18 = NULL, *_59$$18 = NULL, *_60$$18 = NULL, *_57$$19, *_64$$20, *_65$$20 = NULL, *_66$$20 = NULL, *_75$$20 = NULL, *_67$$21 = NULL, *_68$$21, *_70$$23 = NULL, *_71$$23 = NULL, *_73$$23 = NULL, *_74$$23 = NULL, *_72$$24, *_76$$25 = NULL, *_77$$25, *_79$$26 = NULL, *_80$$26 = NULL, *_82$$26 = NULL, *_83$$26 = NULL, *_81$$27; ZEPHIR_MM_GROW(); zephir_get_global(&_FILES, SS("_FILES") TSRMLS_CC); zephir_get_global(&_POST, SS("_POST") TSRMLS_CC); zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } zephir_array_fetch_string(&_1, _SERVER, SL("REQUEST_METHOD"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 62 TSRMLS_CC); _2 = ZEPHIR_IS_STRING(_1, "POST"); if (_2) { _2 = ZEPHIR_IS_EMPTY(_POST); } _3 = _2; if (_3) { _3 = ZEPHIR_IS_EMPTY(_FILES); } _4 = _3; if (_4) { zephir_array_fetch_string(&_5, _SERVER, SL("CONTENT_LENGTH"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 62 TSRMLS_CC); _4 = ZEPHIR_GT_LONG(_5, 0); } _6 = _4; if (!(_6)) { _7 = zephir_array_isset_string(value, SS("error")); if (_7) { zephir_array_fetch_string(&_8, value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 62 TSRMLS_CC); _7 = ZEPHIR_IS_LONG_IDENTICAL(_8, 1); } _6 = _7; } if (_6) { ZEPHIR_INIT_VAR(_9$$4); ZVAL_STRING(_9$$4, "messageIniSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _9$$4); zephir_check_temp_parameter(_9$$4); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_10$$5); ZVAL_STRING(_10$$5, "FileIniSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _10$$5); zephir_check_temp_parameter(_10$$5); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_9$$4); object_init_ex(_9$$4, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_11$$4, "strtr", &_12, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_14$$4); ZVAL_STRING(_14$$4, "code", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_13$$4, this_ptr, "getoption", NULL, 0, _14$$4); zephir_check_temp_parameter(_14$$4); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_14$$4); ZVAL_STRING(_14$$4, "FileIniSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _9$$4, "__construct", &_15, 440, _11$$4, field, _14$$4, _13$$4); zephir_check_temp_parameter(_14$$4); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _9$$4); zephir_check_call_status(); RETURN_MM_BOOL(0); } _16 = !(zephir_array_isset_string(value, SS("error"))); if (!(_16)) { _16 = !(zephir_array_isset_string(value, SS("tmp_name"))); } _17 = _16; if (!(_17)) { zephir_array_fetch_string(&_18, value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 75 TSRMLS_CC); _17 = !ZEPHIR_IS_LONG_IDENTICAL(_18, 0); } _19 = _17; if (!(_19)) { zephir_array_fetch_string(&_20, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 75 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_21, "is_uploaded_file", NULL, 231, _20); zephir_check_call_status(); _19 = !zephir_is_true(_21); } if (_19) { ZEPHIR_INIT_VAR(_22$$6); ZVAL_STRING(_22$$6, "messageEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _22$$6); zephir_check_temp_parameter(_22$$6); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_23$$7); ZVAL_STRING(_23$$7, "FileEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _23$$7); zephir_check_temp_parameter(_23$$7); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_22$$6); object_init_ex(_22$$6, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_24$$6, "strtr", &_12, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_26$$6); ZVAL_STRING(_26$$6, "code", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_25$$6, this_ptr, "getoption", NULL, 0, _26$$6); zephir_check_temp_parameter(_26$$6); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_26$$6); ZVAL_STRING(_26$$6, "FileEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _22$$6, "__construct", &_15, 440, _24$$6, field, _26$$6, _25$$6); zephir_check_temp_parameter(_26$$6); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _22$$6); zephir_check_call_status(); RETURN_MM_BOOL(0); } _27 = !(zephir_array_isset_string(value, SS("name"))); if (!(_27)) { _27 = !(zephir_array_isset_string(value, SS("type"))); } _28 = _27; if (!(_28)) { _28 = !(zephir_array_isset_string(value, SS("size"))); } if (_28) { ZEPHIR_INIT_VAR(_29$$8); ZVAL_STRING(_29$$8, "messageValid", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _29$$8); zephir_check_temp_parameter(_29$$8); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_30$$9); ZVAL_STRING(_30$$9, "FileValid", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _30$$9); zephir_check_temp_parameter(_30$$9); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_29$$8); object_init_ex(_29$$8, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_31$$8, "strtr", &_12, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_33$$8); ZVAL_STRING(_33$$8, "code", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_32$$8, this_ptr, "getoption", NULL, 0, _33$$8); zephir_check_temp_parameter(_33$$8); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_33$$8); ZVAL_STRING(_33$$8, "FileValid", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _29$$8, "__construct", &_15, 440, _31$$8, field, _33$$8, _32$$8); zephir_check_temp_parameter(_33$$8); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _29$$8); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "maxSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_34, this_ptr, "hasoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (zephir_is_true(_34)) { ZEPHIR_INIT_VAR(byteUnits); zephir_create_array(byteUnits, 9, 0 TSRMLS_CC); add_assoc_long_ex(byteUnits, SS("B"), 0); add_assoc_long_ex(byteUnits, SS("K"), 10); add_assoc_long_ex(byteUnits, SS("M"), 20); add_assoc_long_ex(byteUnits, SS("G"), 30); add_assoc_long_ex(byteUnits, SS("T"), 40); add_assoc_long_ex(byteUnits, SS("KB"), 10); add_assoc_long_ex(byteUnits, SS("MB"), 20); add_assoc_long_ex(byteUnits, SS("GB"), 30); add_assoc_long_ex(byteUnits, SS("TB"), 40); ZEPHIR_INIT_VAR(_35$$10); ZVAL_STRING(_35$$10, "maxSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&maxSize, this_ptr, "getoption", NULL, 0, _35$$10); zephir_check_temp_parameter(_35$$10); zephir_check_call_status(); ZEPHIR_INIT_VAR(matches); ZVAL_NULL(matches); ZEPHIR_INIT_VAR(unit); ZVAL_STRING(unit, "B", 1); ZEPHIR_INIT_NVAR(_35$$10); ZEPHIR_INIT_VAR(_36$$10); ZEPHIR_INIT_VAR(_37$$10); zephir_array_keys(_37$$10, byteUnits TSRMLS_CC); zephir_fast_join_str(_36$$10, SL("|"), _37$$10 TSRMLS_CC); ZEPHIR_INIT_VAR(_38$$10); ZEPHIR_CONCAT_SVS(_38$$10, "/^([0-9]+(?:\\.[0-9]+)?)(", _36$$10, ")?$/Di"); zephir_preg_match(_35$$10, _38$$10, maxSize, matches, 0, 0 , 0 TSRMLS_CC); if (zephir_array_isset_long(matches, 2)) { ZEPHIR_OBS_NVAR(unit); zephir_array_fetch_long(&unit, matches, 2, PH_NOISY, "phalcon/validation/validator/file.zep", 111 TSRMLS_CC); } zephir_array_fetch_long(&_39$$10, matches, 1, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 114 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_40$$10, "floatval", &_41, 303, _39$$10); zephir_check_call_status(); ZEPHIR_INIT_VAR(_42$$10); zephir_array_fetch(&_43$$10, byteUnits, unit, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 114 TSRMLS_CC); ZEPHIR_SINIT_VAR(_44$$10); ZVAL_LONG(&_44$$10, 2); zephir_pow_function(_42$$10, &_44$$10, _43$$10); ZEPHIR_INIT_VAR(bytes); mul_function(bytes, _40$$10, _42$$10 TSRMLS_CC); zephir_array_fetch_string(&_45$$10, value, SL("size"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 116 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_40$$10, "floatval", &_41, 303, _45$$10); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_46$$10, "floatval", &_41, 303, bytes); zephir_check_call_status(); if (ZEPHIR_GT(_40$$10, _46$$10)) { ZEPHIR_INIT_VAR(_47$$12); ZVAL_STRING(_47$$12, "messageSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _47$$12); zephir_check_temp_parameter(_47$$12); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); zephir_array_update_string(&replacePairs, SL(":max"), &maxSize, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_48$$13); ZVAL_STRING(_48$$13, "FileSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _48$$13); zephir_check_temp_parameter(_48$$13); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_47$$12); object_init_ex(_47$$12, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_49$$12, "strtr", &_12, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_51$$12); ZVAL_STRING(_51$$12, "code", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_50$$12, this_ptr, "getoption", NULL, 0, _51$$12); zephir_check_temp_parameter(_51$$12); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_51$$12); ZVAL_STRING(_51$$12, "FileSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _47$$12, "__construct", &_15, 440, _49$$12, field, _51$$12, _50$$12); zephir_check_temp_parameter(_51$$12); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _47$$12); zephir_check_call_status(); RETURN_MM_BOOL(0); } } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "allowedTypes", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_52, this_ptr, "hasoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (zephir_is_true(_52)) { ZEPHIR_INIT_VAR(_53$$14); ZVAL_STRING(_53$$14, "allowedTypes", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&types, this_ptr, "getoption", NULL, 0, _53$$14); zephir_check_temp_parameter(_53$$14); zephir_check_call_status(); if (Z_TYPE_P(types) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "Option 'allowedTypes' must be an array", "phalcon/validation/validator/file.zep", 134); return; } if ((zephir_function_exists_ex(SS("finfo_open") TSRMLS_CC) == SUCCESS)) { ZEPHIR_SINIT_VAR(_54$$16); ZVAL_LONG(&_54$$16, 16); ZEPHIR_CALL_FUNCTION(&tmp, "finfo_open", NULL, 228, &_54$$16); zephir_check_call_status(); zephir_array_fetch_string(&_55$$16, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 139 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&mime, "finfo_file", NULL, 229, tmp, _55$$16); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(NULL, "finfo_close", NULL, 230, tmp); zephir_check_call_status(); } else { ZEPHIR_OBS_NVAR(mime); zephir_array_fetch_string(&mime, value, SL("type"), PH_NOISY, "phalcon/validation/validator/file.zep", 143 TSRMLS_CC); } if (!(zephir_fast_in_array(mime, types TSRMLS_CC))) { ZEPHIR_INIT_VAR(_56$$18); ZVAL_STRING(_56$$18, "messageType", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _56$$18); zephir_check_temp_parameter(_56$$18); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_56$$18); zephir_fast_join_str(_56$$18, SL(", "), types TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":types"), &_56$$18, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_57$$19); ZVAL_STRING(_57$$19, "FileType", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _57$$19); zephir_check_temp_parameter(_57$$19); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_56$$18); object_init_ex(_56$$18, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_58$$18, "strtr", &_12, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_60$$18); ZVAL_STRING(_60$$18, "code", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_59$$18, this_ptr, "getoption", NULL, 0, _60$$18); zephir_check_temp_parameter(_60$$18); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_60$$18); ZVAL_STRING(_60$$18, "FileType", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _56$$18, "__construct", &_15, 440, _58$$18, field, _60$$18, _59$$18); zephir_check_temp_parameter(_60$$18); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _56$$18); zephir_check_call_status(); RETURN_MM_BOOL(0); } } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_61, this_ptr, "hasoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _62 = zephir_is_true(_61); if (!(_62)) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_63, this_ptr, "hasoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _62 = zephir_is_true(_63); } if (_62) { zephir_array_fetch_string(&_64$$20, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 160 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&tmp, "getimagesize", NULL, 239, _64$$20); zephir_check_call_status(); ZEPHIR_OBS_VAR(width); zephir_array_fetch_long(&width, tmp, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 161 TSRMLS_CC); ZEPHIR_OBS_VAR(height); zephir_array_fetch_long(&height, tmp, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 162 TSRMLS_CC); ZEPHIR_INIT_VAR(_66$$20); ZVAL_STRING(_66$$20, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_65$$20, this_ptr, "hasoption", NULL, 0, _66$$20); zephir_check_temp_parameter(_66$$20); zephir_check_call_status(); if (zephir_is_true(_65$$20)) { ZEPHIR_INIT_VAR(_68$$21); ZVAL_STRING(_68$$21, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_67$$21, this_ptr, "getoption", NULL, 0, _68$$21); zephir_check_temp_parameter(_68$$21); zephir_check_call_status(); ZEPHIR_INIT_VAR(minResolution); zephir_fast_explode_str(minResolution, SL("x"), _67$$21, LONG_MAX TSRMLS_CC); ZEPHIR_OBS_VAR(minWidth); zephir_array_fetch_long(&minWidth, minResolution, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 166 TSRMLS_CC); ZEPHIR_OBS_VAR(minHeight); zephir_array_fetch_long(&minHeight, minResolution, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 167 TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(minWidth); ZVAL_LONG(minWidth, 1); ZEPHIR_INIT_NVAR(minHeight); ZVAL_LONG(minHeight, 1); } _69$$20 = ZEPHIR_LT(width, minWidth); if (!(_69$$20)) { _69$$20 = ZEPHIR_LT(height, minHeight); } if (_69$$20) { ZEPHIR_INIT_VAR(_70$$23); ZVAL_STRING(_70$$23, "messageMinResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _70$$23); zephir_check_temp_parameter(_70$$23); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_70$$23); ZVAL_STRING(_70$$23, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_71$$23, this_ptr, "getoption", NULL, 0, _70$$23); zephir_check_temp_parameter(_70$$23); zephir_check_call_status(); zephir_array_update_string(&replacePairs, SL(":min"), &_71$$23, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_72$$24); ZVAL_STRING(_72$$24, "FileMinResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _72$$24); zephir_check_temp_parameter(_72$$24); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_70$$23); object_init_ex(_70$$23, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_71$$23, "strtr", &_12, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_74$$23); ZVAL_STRING(_74$$23, "code", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_73$$23, this_ptr, "getoption", NULL, 0, _74$$23); zephir_check_temp_parameter(_74$$23); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_74$$23); ZVAL_STRING(_74$$23, "FileMinResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _70$$23, "__construct", &_15, 440, _71$$23, field, _74$$23, _73$$23); zephir_check_temp_parameter(_74$$23); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _70$$23); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_INIT_NVAR(_66$$20); ZVAL_STRING(_66$$20, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_75$$20, this_ptr, "hasoption", NULL, 0, _66$$20); zephir_check_temp_parameter(_66$$20); zephir_check_call_status(); if (zephir_is_true(_75$$20)) { ZEPHIR_INIT_VAR(_77$$25); ZVAL_STRING(_77$$25, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_76$$25, this_ptr, "getoption", NULL, 0, _77$$25); zephir_check_temp_parameter(_77$$25); zephir_check_call_status(); ZEPHIR_INIT_VAR(maxResolution); zephir_fast_explode_str(maxResolution, SL("x"), _76$$25, LONG_MAX TSRMLS_CC); ZEPHIR_OBS_VAR(maxWidth); zephir_array_fetch_long(&maxWidth, maxResolution, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 188 TSRMLS_CC); ZEPHIR_OBS_VAR(maxHeight); zephir_array_fetch_long(&maxHeight, maxResolution, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 189 TSRMLS_CC); _78$$25 = ZEPHIR_GT(width, maxWidth); if (!(_78$$25)) { _78$$25 = ZEPHIR_GT(height, maxHeight); } if (_78$$25) { ZEPHIR_INIT_VAR(_79$$26); ZVAL_STRING(_79$$26, "messageMaxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _79$$26); zephir_check_temp_parameter(_79$$26); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_79$$26); ZVAL_STRING(_79$$26, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_80$$26, this_ptr, "getoption", NULL, 0, _79$$26); zephir_check_temp_parameter(_79$$26); zephir_check_call_status(); zephir_array_update_string(&replacePairs, SL(":max"), &_80$$26, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_VAR(_81$$27); ZVAL_STRING(_81$$27, "FileMaxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _81$$27); zephir_check_temp_parameter(_81$$27); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_79$$26); object_init_ex(_79$$26, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_80$$26, "strtr", &_12, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_83$$26); ZVAL_STRING(_83$$26, "code", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_82$$26, this_ptr, "getoption", NULL, 0, _83$$26); zephir_check_temp_parameter(_83$$26); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_83$$26); ZVAL_STRING(_83$$26, "FileMaxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _79$$26, "__construct", &_15, 440, _80$$26, field, _83$$26, _82$$26); zephir_check_temp_parameter(_83$$26); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _79$$26); zephir_check_call_status(); RETURN_MM_BOOL(0); } } } RETURN_MM_BOOL(1); }
/** * Extracts a slice from a string/array/traversable object value */ PHP_METHOD(Phalcon_Mvc_View_Engine_Volt, slice) { zephir_fcall_cache_entry *_3 = NULL, *_4 = NULL, *_6 = NULL; zend_bool _1; int start, position, ZEPHIR_LAST_CALL_STATUS; zval *value, *start_param = NULL, *end = NULL, *length, *slice, *_0 = NULL, *_2 = NULL, _5 = zval_used_for_init; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &value, &start_param, &end); if (!start_param) { start = 0; } else { start = zephir_get_intval(start_param); } if (!end) { ZEPHIR_CPY_WRT(end, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(end); } if (Z_TYPE_P(value) == IS_OBJECT) { if (Z_TYPE_P(end) == IS_NULL) { ZEPHIR_INIT_NVAR(end); ZVAL_LONG(end, (zephir_fast_count_int(value TSRMLS_CC) - 1)); } position = 0; ZEPHIR_INIT_VAR(slice); array_init(slice); ZEPHIR_CALL_METHOD(NULL, value, "rewind", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_0, value, "valid", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(_0))) { break; } _1 = position >= start; if (_1) { _1 = ZEPHIR_GE_LONG(end, position); } if (_1) { ZEPHIR_CALL_METHOD(&_2, value, "current", &_3, 0); zephir_check_call_status(); zephir_array_append(&slice, _2, PH_SEPARATE, "phalcon/mvc/view/engine/volt.zep", 231); } ZEPHIR_CALL_METHOD(NULL, value, "next", &_4, 0); zephir_check_call_status(); position++; } RETURN_CCTOR(slice); } ZEPHIR_INIT_VAR(length); if (Z_TYPE_P(end) != IS_NULL) { ZVAL_LONG(length, (((zephir_get_numberval(end) - start)) + 1)); } else { ZVAL_NULL(length); } if (Z_TYPE_P(value) == IS_ARRAY) { ZEPHIR_SINIT_VAR(_5); ZVAL_LONG(&_5, start); ZEPHIR_RETURN_CALL_FUNCTION("array_slice", NULL, 373, value, &_5, length); zephir_check_call_status(); RETURN_MM(); } if ((zephir_function_exists_ex(SS("mb_substr") TSRMLS_CC) == SUCCESS)) { if (Z_TYPE_P(length) != IS_NULL) { ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, start); ZEPHIR_RETURN_CALL_FUNCTION("mb_substr", &_6, 374, value, &_5, length); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, start); ZEPHIR_RETURN_CALL_FUNCTION("mb_substr", &_6, 374, value, &_5); zephir_check_call_status(); RETURN_MM(); } if (Z_TYPE_P(length) != IS_NULL) { ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, start); zephir_substr(return_value, value, zephir_get_intval(&_5), zephir_get_intval(length), 0); RETURN_MM(); } ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, start); zephir_substr(return_value, value, zephir_get_intval(&_5), 0, ZEPHIR_SUBSTR_NO_LENGTH); RETURN_MM(); }
php_stream_filter_status_t userfilter_filter( php_stream *stream, php_stream_filter *thisfilter, php_stream_bucket_brigade *buckets_in, php_stream_bucket_brigade *buckets_out, size_t *bytes_consumed, int flags ) { int ret = PSFS_ERR_FATAL; zval *obj = &thisfilter->abstract; zval func_name; zval retval; zval args[4]; zval zpropname; int call_result; /* the userfilter object probably doesn't exist anymore */ if (CG(unclean_shutdown)) { return ret; } if (!zend_hash_str_exists(Z_OBJPROP_P(obj), "stream", sizeof("stream")-1)) { zval tmp; /* Give the userfilter class a hook back to the stream */ php_stream_to_zval(stream, &tmp); zval_copy_ctor(&tmp); add_property_zval(obj, "stream", &tmp); /* add_property_zval increments the refcount which is unwanted here */ zval_ptr_dtor(&tmp); } ZVAL_STRINGL(&func_name, "filter", sizeof("filter")-1); /* Setup calling arguments */ ZVAL_RES(&args[0], zend_register_resource(buckets_in, le_bucket_brigade)); ZVAL_RES(&args[1], zend_register_resource(buckets_out, le_bucket_brigade)); if (bytes_consumed) { ZVAL_LONG(&args[2], *bytes_consumed); } else { ZVAL_NULL(&args[2]); } ZVAL_BOOL(&args[3], flags & PSFS_FLAG_FLUSH_CLOSE); call_result = call_user_function_ex(NULL, obj, &func_name, &retval, 4, args, 0, NULL); zval_ptr_dtor(&func_name); if (call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF) { convert_to_long(&retval); ret = (int)Z_LVAL(retval); } else if (call_result == FAILURE) { php_error_docref(NULL, E_WARNING, "failed to call filter function"); } if (bytes_consumed) { *bytes_consumed = Z_LVAL_P(&args[2]); } if (buckets_in->head) { php_stream_bucket *bucket = buckets_in->head; php_error_docref(NULL, E_WARNING, "Unprocessed filter buckets remaining on input brigade"); while ((bucket = buckets_in->head)) { /* Remove unconsumed buckets from the brigade */ php_stream_bucket_unlink(bucket); php_stream_bucket_delref(bucket); } } if (ret != PSFS_PASS_ON) { php_stream_bucket *bucket = buckets_out->head; while (bucket != NULL) { php_stream_bucket_unlink(bucket); php_stream_bucket_delref(bucket); bucket = buckets_out->head; } } /* filter resources are cleaned up by the stream destructor, * keeping a reference to the stream resource here would prevent it * from being destroyed properly */ ZVAL_STRINGL(&zpropname, "stream", sizeof("stream")-1); Z_OBJ_HANDLER_P(obj, unset_property)(obj, &zpropname, NULL); zval_ptr_dtor(&zpropname); zval_ptr_dtor(&args[3]); zval_ptr_dtor(&args[2]); zval_ptr_dtor(&args[1]); zval_ptr_dtor(&args[0]); return ret; }
PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) { const unsigned char *cursor, *limit, *marker, *start; zval **rval_ref; limit = max; cursor = *p; if (YYCURSOR >= YYLIMIT) { return 0; } if (var_hash && cursor[0] != 'R') { var_push(var_hash, rval); } start = cursor; { YYCTYPE yych; static const unsigned char yybm[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; if ((YYLIMIT - YYCURSOR) < 7) YYFILL(7); yych = *YYCURSOR; switch (yych) { case 'C': case 'O': goto yy13; case 'N': goto yy5; case 'R': goto yy2; case 'S': goto yy10; case 'a': goto yy11; case 'b': goto yy6; case 'd': goto yy8; case 'i': goto yy7; case 'o': goto yy12; case 'r': goto yy4; case 's': goto yy9; case '}': goto yy14; default: goto yy16; } yy2: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy95; yy3: { return 0; } yy4: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy89; goto yy3; yy5: yych = *++YYCURSOR; if (yych == ';') goto yy87; goto yy3; yy6: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy83; goto yy3; yy7: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy77; goto yy3; yy8: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy53; goto yy3; yy9: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy46; goto yy3; yy10: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy39; goto yy3; yy11: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy32; goto yy3; yy12: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy25; goto yy3; yy13: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy17; goto yy3; yy14: ++YYCURSOR; { /* this is the case where we have less data than planned */ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unexpected end of serialized data"); return 0; /* not sure if it should be 0 or 1 here? */ } yy16: yych = *++YYCURSOR; goto yy3; yy17: yych = *++YYCURSOR; if (yybm[0+yych] & 128) { goto yy20; } if (yych == '+') goto yy19; yy18: YYCURSOR = YYMARKER; goto yy3; yy19: yych = *++YYCURSOR; if (yybm[0+yych] & 128) { goto yy20; } goto yy18; yy20: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; if (yybm[0+yych] & 128) { goto yy20; } if (yych != ':') goto yy18; yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; { size_t len, len2, len3, maxlen; long elements; char *class_name; zend_class_entry *ce; zend_class_entry **pce; int incomplete_class = 0; int custom_object = 0; zval *user_func; zval *retval_ptr; zval **args[1]; zval *arg_func_name; if (*start == 'C') { custom_object = 1; } INIT_PZVAL(*rval); len2 = len = parse_uiv(start + 2); maxlen = max - YYCURSOR; if (maxlen < len || len == 0) { *p = start + 2; return 0; } class_name = (char*)YYCURSOR; YYCURSOR += len; if (*(YYCURSOR) != '"') { *p = YYCURSOR; return 0; } if (*(YYCURSOR+1) != ':') { *p = YYCURSOR+1; return 0; } len3 = strspn(class_name, "0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377\\"); if (len3 != len) { *p = YYCURSOR + len3 - len; return 0; } class_name = estrndup(class_name, len); do { /* Try to find class directly */ BG(serialize_lock)++; if (zend_lookup_class(class_name, len2, &pce TSRMLS_CC) == SUCCESS) { BG(serialize_lock)--; if (EG(exception)) { efree(class_name); return 0; } ce = *pce; break; } BG(serialize_lock)--; if (EG(exception)) { efree(class_name); return 0; } /* Check for unserialize callback */ if ((PG(unserialize_callback_func) == NULL) || (PG(unserialize_callback_func)[0] == '\0')) { incomplete_class = 1; ce = PHP_IC_ENTRY; break; } /* Call unserialize callback */ MAKE_STD_ZVAL(user_func); ZVAL_STRING(user_func, PG(unserialize_callback_func), 1); args[0] = &arg_func_name; MAKE_STD_ZVAL(arg_func_name); ZVAL_STRING(arg_func_name, class_name, 1); BG(serialize_lock)++; if (call_user_function_ex(CG(function_table), NULL, user_func, &retval_ptr, 1, args, 0, NULL TSRMLS_CC) != SUCCESS) { BG(serialize_lock)--; if (EG(exception)) { efree(class_name); zval_ptr_dtor(&user_func); zval_ptr_dtor(&arg_func_name); return 0; } php_error_docref(NULL TSRMLS_CC, E_WARNING, "defined (%s) but not found", user_func->value.str.val); incomplete_class = 1; ce = PHP_IC_ENTRY; zval_ptr_dtor(&user_func); zval_ptr_dtor(&arg_func_name); break; } BG(serialize_lock)--; if (retval_ptr) { zval_ptr_dtor(&retval_ptr); } if (EG(exception)) { efree(class_name); zval_ptr_dtor(&user_func); zval_ptr_dtor(&arg_func_name); return 0; } /* The callback function may have defined the class */ if (zend_lookup_class(class_name, len2, &pce TSRMLS_CC) == SUCCESS) { ce = *pce; } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Function %s() hasn't defined the class it was called for", user_func->value.str.val); incomplete_class = 1; ce = PHP_IC_ENTRY; } zval_ptr_dtor(&user_func); zval_ptr_dtor(&arg_func_name); break; } while (1); *p = YYCURSOR; if (custom_object) { int ret; ret = object_custom(UNSERIALIZE_PASSTHRU, ce); if (ret && incomplete_class) { php_store_class_name(*rval, class_name, len2); } efree(class_name); return ret; } elements = object_common1(UNSERIALIZE_PASSTHRU, ce); if (incomplete_class) { php_store_class_name(*rval, class_name, len2); } efree(class_name); return object_common2(UNSERIALIZE_PASSTHRU, elements); } yy25: yych = *++YYCURSOR; if (yych <= ',') { if (yych != '+') goto yy18; } else { if (yych <= '-') goto yy26; if (yych <= '/') goto yy18; if (yych <= '9') goto yy27; goto yy18; } yy26: yych = *++YYCURSOR; if (yych <= '/') goto yy18; if (yych >= ':') goto yy18; yy27: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; if (yych <= '/') goto yy18; if (yych <= '9') goto yy27; if (yych >= ';') goto yy18; yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; { INIT_PZVAL(*rval); return object_common2(UNSERIALIZE_PASSTHRU, object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR)); } yy32: yych = *++YYCURSOR; if (yych == '+') goto yy33; if (yych <= '/') goto yy18; if (yych <= '9') goto yy34; goto yy18; yy33: yych = *++YYCURSOR; if (yych <= '/') goto yy18; if (yych >= ':') goto yy18; yy34: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; if (yych <= '/') goto yy18; if (yych <= '9') goto yy34; if (yych >= ';') goto yy18; yych = *++YYCURSOR; if (yych != '{') goto yy18; ++YYCURSOR; { long elements = parse_iv(start + 2); /* use iv() not uiv() in order to check data range */ *p = YYCURSOR; if (elements < 0) { return 0; } INIT_PZVAL(*rval); array_init_size(*rval, elements); if (!process_nested_data(UNSERIALIZE_PASSTHRU, Z_ARRVAL_PP(rval), elements, 0)) { return 0; } return finish_nested_data(UNSERIALIZE_PASSTHRU); } yy39: yych = *++YYCURSOR; if (yych == '+') goto yy40; if (yych <= '/') goto yy18; if (yych <= '9') goto yy41; goto yy18; yy40: yych = *++YYCURSOR; if (yych <= '/') goto yy18; if (yych >= ':') goto yy18; yy41: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; if (yych <= '/') goto yy18; if (yych <= '9') goto yy41; if (yych >= ';') goto yy18; yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; { size_t len, maxlen; char *str; len = parse_uiv(start + 2); maxlen = max - YYCURSOR; if (maxlen < len) { *p = start + 2; return 0; } if ((str = unserialize_str(&YYCURSOR, &len, maxlen)) == NULL) { return 0; } if (*(YYCURSOR) != '"') { efree(str); *p = YYCURSOR; return 0; } YYCURSOR += 2; *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_STRINGL(*rval, str, len, 0); return 1; } yy46: yych = *++YYCURSOR; if (yych == '+') goto yy47; if (yych <= '/') goto yy18; if (yych <= '9') goto yy48; goto yy18; yy47: yych = *++YYCURSOR; if (yych <= '/') goto yy18; if (yych >= ':') goto yy18; yy48: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; if (yych <= '/') goto yy18; if (yych <= '9') goto yy48; if (yych >= ';') goto yy18; yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; { size_t len, maxlen; char *str; len = parse_uiv(start + 2); maxlen = max - YYCURSOR; if (maxlen < len) { *p = start + 2; return 0; } str = (char*)YYCURSOR; YYCURSOR += len; if (*(YYCURSOR) != '"') { *p = YYCURSOR; return 0; } YYCURSOR += 2; *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_STRINGL(*rval, str, len, 1); return 1; } yy53: yych = *++YYCURSOR; if (yych <= '/') { if (yych <= ',') { if (yych == '+') goto yy57; goto yy18; } else { if (yych <= '-') goto yy55; if (yych <= '.') goto yy60; goto yy18; } } else { if (yych <= 'I') { if (yych <= '9') goto yy58; if (yych <= 'H') goto yy18; goto yy56; } else { if (yych != 'N') goto yy18; } } yych = *++YYCURSOR; if (yych == 'A') goto yy76; goto yy18; yy55: yych = *++YYCURSOR; if (yych <= '/') { if (yych == '.') goto yy60; goto yy18; } else { if (yych <= '9') goto yy58; if (yych != 'I') goto yy18; } yy56: yych = *++YYCURSOR; if (yych == 'N') goto yy72; goto yy18; yy57: yych = *++YYCURSOR; if (yych == '.') goto yy60; if (yych <= '/') goto yy18; if (yych >= ':') goto yy18; yy58: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4); yych = *YYCURSOR; if (yych <= ':') { if (yych <= '.') { if (yych <= '-') goto yy18; goto yy70; } else { if (yych <= '/') goto yy18; if (yych <= '9') goto yy58; goto yy18; } } else { if (yych <= 'E') { if (yych <= ';') goto yy63; if (yych <= 'D') goto yy18; goto yy65; } else { if (yych == 'e') goto yy65; goto yy18; } } yy60: yych = *++YYCURSOR; if (yych <= '/') goto yy18; if (yych >= ':') goto yy18; yy61: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4); yych = *YYCURSOR; if (yych <= ';') { if (yych <= '/') goto yy18; if (yych <= '9') goto yy61; if (yych <= ':') goto yy18; } else { if (yych <= 'E') { if (yych <= 'D') goto yy18; goto yy65; } else { if (yych == 'e') goto yy65; goto yy18; } } yy63: ++YYCURSOR; { #if SIZEOF_LONG == 4 use_double: #endif *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_DOUBLE(*rval, zend_strtod((const char *)start + 2, NULL)); return 1; } yy65: yych = *++YYCURSOR; if (yych <= ',') { if (yych != '+') goto yy18; } else { if (yych <= '-') goto yy66; if (yych <= '/') goto yy18; if (yych <= '9') goto yy67; goto yy18; } yy66: yych = *++YYCURSOR; if (yych <= ',') { if (yych == '+') goto yy69; goto yy18; } else { if (yych <= '-') goto yy69; if (yych <= '/') goto yy18; if (yych >= ':') goto yy18; } yy67: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; if (yych <= '/') goto yy18; if (yych <= '9') goto yy67; if (yych == ';') goto yy63; goto yy18; yy69: yych = *++YYCURSOR; if (yych <= '/') goto yy18; if (yych <= '9') goto yy67; goto yy18; yy70: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4); yych = *YYCURSOR; if (yych <= ';') { if (yych <= '/') goto yy18; if (yych <= '9') goto yy70; if (yych <= ':') goto yy18; goto yy63; } else { if (yych <= 'E') { if (yych <= 'D') goto yy18; goto yy65; } else { if (yych == 'e') goto yy65; goto yy18; } } yy72: yych = *++YYCURSOR; if (yych != 'F') goto yy18; yy73: yych = *++YYCURSOR; if (yych != ';') goto yy18; ++YYCURSOR; { *p = YYCURSOR; INIT_PZVAL(*rval); if (!strncmp(start + 2, "NAN", 3)) { ZVAL_DOUBLE(*rval, php_get_nan()); } else if (!strncmp(start + 2, "INF", 3)) { ZVAL_DOUBLE(*rval, php_get_inf()); } else if (!strncmp(start + 2, "-INF", 4)) { ZVAL_DOUBLE(*rval, -php_get_inf()); } return 1; } yy76: yych = *++YYCURSOR; if (yych == 'N') goto yy73; goto yy18; yy77: yych = *++YYCURSOR; if (yych <= ',') { if (yych != '+') goto yy18; } else { if (yych <= '-') goto yy78; if (yych <= '/') goto yy18; if (yych <= '9') goto yy79; goto yy18; } yy78: yych = *++YYCURSOR; if (yych <= '/') goto yy18; if (yych >= ':') goto yy18; yy79: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; if (yych <= '/') goto yy18; if (yych <= '9') goto yy79; if (yych != ';') goto yy18; ++YYCURSOR; { #if SIZEOF_LONG == 4 int digits = YYCURSOR - start - 3; if (start[2] == '-' || start[2] == '+') { digits--; } /* Use double for large long values that were serialized on a 64-bit system */ if (digits >= MAX_LENGTH_OF_LONG - 1) { if (digits == MAX_LENGTH_OF_LONG - 1) { int cmp = strncmp(YYCURSOR - MAX_LENGTH_OF_LONG, long_min_digits, MAX_LENGTH_OF_LONG - 1); if (!(cmp < 0 || (cmp == 0 && start[2] == '-'))) { goto use_double; } } else { goto use_double; } } #endif *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_LONG(*rval, parse_iv(start + 2)); return 1; } yy83: yych = *++YYCURSOR; if (yych <= '/') goto yy18; if (yych >= '2') goto yy18; yych = *++YYCURSOR; if (yych != ';') goto yy18; ++YYCURSOR; { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_BOOL(*rval, parse_iv(start + 2)); return 1; } yy87: ++YYCURSOR; { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_NULL(*rval); return 1; } yy89: yych = *++YYCURSOR; if (yych <= ',') { if (yych != '+') goto yy18; } else { if (yych <= '-') goto yy90; if (yych <= '/') goto yy18; if (yych <= '9') goto yy91; goto yy18; } yy90: yych = *++YYCURSOR; if (yych <= '/') goto yy18; if (yych >= ':') goto yy18; yy91: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; if (yych <= '/') goto yy18; if (yych <= '9') goto yy91; if (yych != ';') goto yy18; ++YYCURSOR; { long id; *p = YYCURSOR; if (!var_hash) return 0; id = parse_iv(start + 2) - 1; if (id == -1 || var_access(var_hash, id, &rval_ref) != SUCCESS) { return 0; } if (*rval == *rval_ref) return 0; if (*rval != NULL) { var_push_dtor_no_addref(var_hash, rval); } *rval = *rval_ref; Z_ADDREF_PP(rval); Z_UNSET_ISREF_PP(rval); return 1; } yy95: yych = *++YYCURSOR; if (yych <= ',') { if (yych != '+') goto yy18; } else { if (yych <= '-') goto yy96; if (yych <= '/') goto yy18; if (yych <= '9') goto yy97; goto yy18; } yy96: yych = *++YYCURSOR; if (yych <= '/') goto yy18; if (yych >= ':') goto yy18; yy97: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; if (yych <= '/') goto yy18; if (yych <= '9') goto yy97; if (yych != ';') goto yy18; ++YYCURSOR; { long id; *p = YYCURSOR; if (!var_hash) return 0; id = parse_iv(start + 2) - 1; if (id == -1 || var_access(var_hash, id, &rval_ref) != SUCCESS) { return 0; } if (*rval != NULL) { zval_ptr_dtor(rval); } *rval = *rval_ref; Z_ADDREF_PP(rval); Z_SET_ISREF_PP(rval); return 1; } } return 0; }
/* {{{ encoding string readonly=no URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Entity3-encoding Since: DOM Level 3 */ int dom_entity_encoding_read(dom_object *obj, zval *retval) { ZVAL_NULL(retval); return SUCCESS; }
static int odbc_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *param, enum pdo_param_event event_type) { pdo_odbc_stmt *S = (pdo_odbc_stmt*)stmt->driver_data; RETCODE rc; SWORD sqltype = 0, ctype = 0, scale = 0, nullable = 0; SQLULEN precision = 0; pdo_odbc_param *P; zval *parameter; /* we're only interested in parameters for prepared SQL right now */ if (param->is_param) { switch (event_type) { case PDO_PARAM_EVT_FETCH_PRE: case PDO_PARAM_EVT_FETCH_POST: case PDO_PARAM_EVT_NORMALIZE: /* Do nothing */ break; case PDO_PARAM_EVT_FREE: P = param->driver_data; if (P) { efree(P); } break; case PDO_PARAM_EVT_ALLOC: { /* figure out what we're doing */ switch (PDO_PARAM_TYPE(param->param_type)) { case PDO_PARAM_LOB: break; case PDO_PARAM_STMT: return 0; default: break; } rc = SQLDescribeParam(S->stmt, (SQLUSMALLINT) param->paramno+1, &sqltype, &precision, &scale, &nullable); if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { /* MS Access, for instance, doesn't support SQLDescribeParam, * so we need to guess */ sqltype = PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_LOB ? SQL_LONGVARBINARY : SQL_LONGVARCHAR; precision = 4000; scale = 5; nullable = 1; if (param->max_value_len > 0) { precision = param->max_value_len; } } if (sqltype == SQL_BINARY || sqltype == SQL_VARBINARY || sqltype == SQL_LONGVARBINARY) { ctype = SQL_C_BINARY; } else { ctype = SQL_C_CHAR; } P = emalloc(sizeof(*P)); param->driver_data = P; P->len = 0; /* is re-populated each EXEC_PRE */ P->outbuf = NULL; P->is_unicode = pdo_odbc_sqltype_is_unicode(S, sqltype); if (P->is_unicode) { /* avoid driver auto-translation: we'll do it ourselves */ ctype = SQL_C_BINARY; } if ((param->param_type & PDO_PARAM_INPUT_OUTPUT) == PDO_PARAM_INPUT_OUTPUT) { P->paramtype = SQL_PARAM_INPUT_OUTPUT; } else if (param->max_value_len <= 0) { P->paramtype = SQL_PARAM_INPUT; } else { P->paramtype = SQL_PARAM_OUTPUT; } if (P->paramtype != SQL_PARAM_INPUT) { if (PDO_PARAM_TYPE(param->param_type) != PDO_PARAM_NULL) { /* need an explicit buffer to hold result */ P->len = param->max_value_len > 0 ? param->max_value_len : precision; if (P->is_unicode) { P->len *= 2; } P->outbuf = emalloc(P->len + (P->is_unicode ? 2:1)); } } if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_LOB && P->paramtype != SQL_PARAM_INPUT) { pdo_odbc_stmt_error("Can't bind a lob for output"); return 0; } rc = SQLBindParameter(S->stmt, (SQLUSMALLINT) param->paramno+1, P->paramtype, ctype, sqltype, precision, scale, P->paramtype == SQL_PARAM_INPUT ? (SQLPOINTER)param : P->outbuf, P->len, &P->len ); if (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO) { return 1; } pdo_odbc_stmt_error("SQLBindParameter"); return 0; } case PDO_PARAM_EVT_EXEC_PRE: P = param->driver_data; if (!Z_ISREF(param->parameter)) { parameter = ¶m->parameter; } else { parameter = Z_REFVAL(param->parameter); } if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_LOB) { if (Z_TYPE_P(parameter) == IS_RESOURCE) { php_stream *stm; php_stream_statbuf sb; php_stream_from_zval_no_verify(stm, parameter); if (!stm) { return 0; } if (0 == php_stream_stat(stm, &sb)) { if (P->outbuf) { int len, amount; char *ptr = P->outbuf; char *end = P->outbuf + P->len; P->len = 0; do { amount = end - ptr; if (amount == 0) { break; } if (amount > 8192) amount = 8192; len = php_stream_read(stm, ptr, amount); if (len == 0) { break; } ptr += len; P->len += len; } while (1); } else { P->len = SQL_LEN_DATA_AT_EXEC(sb.sb.st_size); } } else { if (P->outbuf) { P->len = 0; } else { P->len = SQL_LEN_DATA_AT_EXEC(0); } } } else { convert_to_string(parameter); if (P->outbuf) { P->len = Z_STRLEN_P(parameter); memcpy(P->outbuf, Z_STRVAL_P(parameter), P->len); } else { P->len = SQL_LEN_DATA_AT_EXEC(Z_STRLEN_P(parameter)); } } } else if (Z_TYPE_P(parameter) == IS_NULL || PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_NULL) { P->len = SQL_NULL_DATA; } else { convert_to_string(parameter); if (P->outbuf) { zend_ulong ulen; switch (pdo_odbc_utf82ucs2(stmt, P->is_unicode, Z_STRVAL_P(parameter), Z_STRLEN_P(parameter), &ulen)) { case PDO_ODBC_CONV_FAIL: case PDO_ODBC_CONV_NOT_REQUIRED: P->len = Z_STRLEN_P(parameter); memcpy(P->outbuf, Z_STRVAL_P(parameter), P->len); break; case PDO_ODBC_CONV_OK: P->len = ulen; memcpy(P->outbuf, S->convbuf, P->len); break; } } else { P->len = SQL_LEN_DATA_AT_EXEC(Z_STRLEN_P(parameter)); } } return 1; case PDO_PARAM_EVT_EXEC_POST: P = param->driver_data; if (P->outbuf) { zend_ulong ulen; char *srcbuf; zend_ulong srclen = 0; if (Z_ISREF(param->parameter)) { parameter = Z_REFVAL(param->parameter); } else { parameter = ¶m->parameter; } zval_ptr_dtor(parameter); ZVAL_NULL(parameter); switch (P->len) { case SQL_NULL_DATA: break; default: switch (pdo_odbc_ucs22utf8(stmt, P->is_unicode, P->outbuf, P->len, &ulen)) { case PDO_ODBC_CONV_FAIL: /* something fishy, but allow it to come back as binary */ case PDO_ODBC_CONV_NOT_REQUIRED: srcbuf = P->outbuf; srclen = P->len; break; case PDO_ODBC_CONV_OK: srcbuf = S->convbuf; srclen = ulen; break; } ZVAL_NEW_STR(parameter, zend_string_alloc(srclen, 0)); memcpy(Z_STRVAL_P(parameter), srcbuf, srclen); Z_STRVAL_P(parameter)[Z_STRLEN_P(parameter)] = '\0'; } } return 1; } } return 1; }
/** * Initialize the metadata for certain table */ PHP_METHOD(Phalcon_Mvc_Model_MetaData, _initialize) { zend_long ZEPHIR_LAST_CALL_STATUS; zval *model, model_sub, *key, key_sub, *table, table_sub, *schema, schema_sub, strategy, className, metaData, data, modelMetadata, modelColumnMap, dependencyInjector, keyName, prefixKey, _2, _0$$8, _1$$8; zval *this_ptr = getThis(); ZVAL_UNDEF(&model_sub); ZVAL_UNDEF(&key_sub); ZVAL_UNDEF(&table_sub); ZVAL_UNDEF(&schema_sub); ZVAL_UNDEF(&strategy); ZVAL_UNDEF(&className); ZVAL_UNDEF(&metaData); ZVAL_UNDEF(&data); ZVAL_UNDEF(&modelMetadata); ZVAL_UNDEF(&modelColumnMap); ZVAL_UNDEF(&dependencyInjector); ZVAL_UNDEF(&keyName); ZVAL_UNDEF(&prefixKey); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_0$$8); ZVAL_UNDEF(&_1$$8); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &model, &key, &table, &schema); ZEPHIR_INIT_VAR(&strategy); ZVAL_NULL(&strategy); ZEPHIR_INIT_VAR(&className); zephir_get_class(&className, model, 0 TSRMLS_CC); if (Z_TYPE_P(key) != IS_NULL) { ZEPHIR_OBS_VAR(&metaData); zephir_read_property(&metaData, this_ptr, SL("_metaData"), PH_NOISY_CC); if (!(zephir_array_isset(&metaData, key))) { ZEPHIR_INIT_VAR(&prefixKey); ZEPHIR_CONCAT_SV(&prefixKey, "meta-", key); ZEPHIR_CALL_METHOD(&data, this_ptr, "read", NULL, 0, &prefixKey); zephir_check_call_status(); if (Z_TYPE_P(&data) != IS_NULL) { zephir_update_property_array(this_ptr, SL("_metaData"), key, &data TSRMLS_CC); } else { if ((zephir_method_exists_ex(model, SL("metadata") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&modelMetadata, model, "metadata", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(&modelMetadata) != IS_ARRAY) { ZEPHIR_INIT_VAR(&_0$$8); object_init_ex(&_0$$8, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_VAR(&_1$$8); ZEPHIR_CONCAT_SV(&_1$$8, "Invalid meta-data for model ", &className); ZEPHIR_CALL_METHOD(NULL, &_0$$8, "__construct", NULL, 4, &_1$$8); zephir_check_call_status(); zephir_throw_exception_debug(&_0$$8, "phalcon/mvc/model/metadata.zep", 113 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } else { ZEPHIR_OBS_VAR(&dependencyInjector); zephir_read_property(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&strategy, this_ptr, "getstrategy", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&modelMetadata, &strategy, "getmetadata", NULL, 0, model, &dependencyInjector); zephir_check_call_status(); } zephir_update_property_array(this_ptr, SL("_metaData"), key, &modelMetadata TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", NULL, 0, &prefixKey, &modelMetadata); zephir_check_call_status(); } } } if (!(ZEPHIR_GLOBAL(orm).column_renaming)) { RETURN_MM_NULL(); } ZEPHIR_INIT_VAR(&keyName); zephir_fast_strtolower(&keyName, &className); zephir_read_property(&_2, this_ptr, SL("_columnMap"), PH_NOISY_CC | PH_READONLY); if (zephir_array_isset(&_2, &keyName)) { RETURN_MM_NULL(); } ZEPHIR_INIT_NVAR(&prefixKey); ZEPHIR_CONCAT_SV(&prefixKey, "map-", &keyName); ZEPHIR_CALL_METHOD(&data, this_ptr, "read", NULL, 0, &prefixKey); zephir_check_call_status(); if (Z_TYPE_P(&data) != IS_NULL) { zephir_update_property_array(this_ptr, SL("_columnMap"), &keyName, &data TSRMLS_CC); RETURN_MM_NULL(); } if (Z_TYPE_P(&strategy) != IS_OBJECT) { ZEPHIR_OBS_NVAR(&dependencyInjector); zephir_read_property(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&strategy, this_ptr, "getstrategy", NULL, 0); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&modelColumnMap, &strategy, "getcolumnmaps", NULL, 0, model, &dependencyInjector); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("_columnMap"), &keyName, &modelColumnMap TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", NULL, 0, &prefixKey, &modelColumnMap); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); }
/** * 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);}
PHP_COM_DOTNET_API int php_com_zval_from_variant(zval *z, VARIANT *v, int codepage TSRMLS_DC) { OLECHAR *olestring = NULL; int ret = SUCCESS; switch (V_VT(v)) { case VT_EMPTY: case VT_NULL: case VT_VOID: ZVAL_NULL(z); break; case VT_UI1: ZVAL_LONG(z, (long)V_UI1(v)); break; case VT_I1: ZVAL_LONG(z, (long)V_I1(v)); break; case VT_UI2: ZVAL_LONG(z, (long)V_UI2(v)); break; case VT_I2: ZVAL_LONG(z, (long)V_I2(v)); break; case VT_UI4: /* TODO: promote to double if large? */ ZVAL_LONG(z, (long)V_UI4(v)); break; case VT_I4: ZVAL_LONG(z, (long)V_I4(v)); break; case VT_INT: ZVAL_LONG(z, V_INT(v)); break; case VT_UINT: /* TODO: promote to double if large? */ ZVAL_LONG(z, (long)V_UINT(v)); break; case VT_R4: ZVAL_DOUBLE(z, (double)V_R4(v)); break; case VT_R8: ZVAL_DOUBLE(z, V_R8(v)); break; case VT_BOOL: ZVAL_BOOL(z, V_BOOL(v) ? 1 : 0); break; case VT_BSTR: olestring = V_BSTR(v); if (olestring) { Z_TYPE_P(z) = IS_STRING; Z_STRVAL_P(z) = php_com_olestring_to_string(olestring, &Z_STRLEN_P(z), codepage TSRMLS_CC); olestring = NULL; } break; case VT_UNKNOWN: if (V_UNKNOWN(v) != NULL) { IDispatch *disp; if (SUCCEEDED(IUnknown_QueryInterface(V_UNKNOWN(v), &IID_IDispatch, &disp))) { php_com_wrap_dispatch(z, disp, codepage TSRMLS_CC); IDispatch_Release(disp); } else { ret = FAILURE; } } break; case VT_DISPATCH: if (V_DISPATCH(v) != NULL) { php_com_wrap_dispatch(z, V_DISPATCH(v), codepage TSRMLS_CC); } break; case VT_VARIANT: /* points to another variant */ return php_com_zval_from_variant(z, V_VARIANTREF(v), codepage TSRMLS_CC); default: php_com_wrap_variant(z, v, codepage TSRMLS_CC); } if (olestring) { efree(olestring); } if (ret == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "variant->zval: conversion from 0x%x ret=%d", V_VT(v), ret); } return ret; }
/** * Lists table indexes * * @param string $table * @param string $schema * @return Phalcon\Db\Index[] */ PHP_METHOD(Phalcon_Db_Adapter_Pdo_Sqlite, describeIndexes){ zval *table = NULL, *schema = NULL, *dialect = NULL, *fetch_assoc = NULL, *sql = NULL, *sql2 = NULL; zval *describe = NULL, *indexes = NULL, *index = NULL, *key_name = NULL, *empty_arr = NULL, *column = NULL, *describe2 = NULL; zval *column_name = NULL, *index_objects = NULL, *index_columns = NULL; zval *name = NULL; HashTable *ah0, *ah1, *ah2; HashPosition hp0, hp1, hp2; zval **hd, **hd2; char *hash_index; uint hash_index_len; ulong hash_num; int hash_type; 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(dialect); phalcon_read_property(&dialect, this_ptr, SL("_dialect"), PH_NOISY_CC); PHALCON_INIT_VAR(fetch_assoc); phalcon_get_class_constant(fetch_assoc, phalcon_db_ce, SL("FETCH_ASSOC") TSRMLS_CC); PHALCON_INIT_VAR(sql); PHALCON_CALL_METHOD_PARAMS_2(sql, dialect, "describeindexes", table, schema, PH_NO_CHECK); PHALCON_INIT_VAR(describe); PHALCON_CALL_METHOD_PARAMS_2(describe, this_ptr, "fetchall", sql, fetch_assoc, PH_NO_CHECK); PHALCON_INIT_VAR(indexes); array_init(indexes); 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(index); PHALCON_INIT_VAR(key_name); phalcon_array_fetch_string(&key_name, index, SL("name"), PH_NOISY_CC); eval_int = phalcon_array_isset(indexes, key_name); if (!eval_int) { PHALCON_INIT_VAR(empty_arr); array_init(empty_arr); phalcon_array_update_zval(&indexes, key_name, &empty_arr, PH_COPY | PH_SEPARATE TSRMLS_CC); } // fetch index columns PHALCON_INIT_VAR(sql2); PHALCON_CALL_METHOD_PARAMS_1(sql2, dialect, "describeIndex", key_name, PH_NO_CHECK); PHALCON_INIT_VAR(describe2); PHALCON_CALL_METHOD_PARAMS_2(describe2, this_ptr, "fetchall", sql2, fetch_assoc, PH_NO_CHECK); if (phalcon_valid_foreach(describe2 TSRMLS_CC)) { ah2 = Z_ARRVAL_P(describe2); zend_hash_internal_pointer_reset_ex(ah2, &hp2); ph_cycle_start_2: if(zend_hash_get_current_data_ex(ah2, (void**) &hd2, &hp2) != SUCCESS){ goto ph_cycle_end_2; } PHALCON_INIT_VAR(column); ZVAL_ZVAL(column, *hd2, 1, 0); PHALCON_INIT_VAR(column_name); phalcon_array_fetch_string(&column_name, column, SL("name"), PH_NOISY_CC); phalcon_array_update_append_multi_2(&indexes, key_name, column_name, 0 TSRMLS_CC); zend_hash_move_forward_ex(ah2, &hp2); goto ph_cycle_start_2; ph_cycle_end_2: if(0){} } zend_hash_move_forward_ex(ah0, &hp0); goto ph_cycle_start_0; ph_cycle_end_0: PHALCON_INIT_VAR(index_objects); array_init(index_objects); if (!phalcon_valid_foreach(indexes TSRMLS_CC)) { return; } ah1 = Z_ARRVAL_P(indexes); zend_hash_internal_pointer_reset_ex(ah1, &hp1); ph_cycle_start_1: if(zend_hash_get_current_data_ex(ah1, (void**) &hd, &hp1) != SUCCESS){ goto ph_cycle_end_1; } PHALCON_INIT_VAR(name); PHALCON_GET_FOREACH_KEY(name, ah1, hp1); PHALCON_GET_FOREACH_VALUE(index_columns); PHALCON_INIT_VAR(index); object_init_ex(index, phalcon_db_index_ce); PHALCON_CALL_METHOD_PARAMS_2_NORETURN(index, "__construct", name, index_columns, PH_CHECK); phalcon_array_update_zval(&index_objects, name, &index, PH_COPY | PH_SEPARATE TSRMLS_CC); zend_hash_move_forward_ex(ah1, &hp1); goto ph_cycle_start_1; ph_cycle_end_1: RETURN_CTOR(index_objects);}
/** * Produce the routing parameters from the rewrite information */ PHP_METHOD(Phalcon_Mvc_Router_Annotations, handle) { zephir_nts_static zephir_fcall_cache_entry *_19 = NULL; zephir_fcall_cache_entry *_6 = NULL, *_10 = NULL, *_18 = NULL; HashTable *_2, *_8, *_12, *_16; HashPosition _1, _7, _11, _15; int ZEPHIR_LAST_CALL_STATUS; zval *uri_param = NULL, *realUri = NULL, *annotationsService = NULL, *handlers, *controllerSuffix, *scope = NULL, *prefix = NULL, *dependencyInjector = NULL, *handler = NULL, *controllerName = NULL, *lowerControllerName = NULL, *namespaceName = NULL, *moduleName = NULL, *sufixed = NULL, *handlerAnnotations = NULL, *classAnnotations = NULL, *annotations = NULL, *annotation = NULL, *methodAnnotations = NULL, *lowercased = NULL, *method = NULL, *collection = NULL, *_0, **_3, *_4, *_5 = NULL, **_9, **_13, *_14 = NULL, **_17; zval *uri = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &uri_param); if (!uri_param) { ZEPHIR_INIT_VAR(uri); ZVAL_EMPTY_STRING(uri); } else { if (unlikely(Z_TYPE_P(uri_param) != IS_STRING && Z_TYPE_P(uri_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'uri' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(uri_param) == IS_STRING)) { zephir_get_strval(uri, uri_param); } else { ZEPHIR_INIT_VAR(uri); ZVAL_EMPTY_STRING(uri); } } if (!(uri && Z_STRLEN_P(uri))) { ZEPHIR_CALL_METHOD(&realUri, this_ptr, "getrewriteuri", NULL); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(realUri, uri); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_processed"), PH_NOISY_CC); if (!(zephir_is_true(_0))) { ZEPHIR_INIT_VAR(annotationsService); ZVAL_NULL(annotationsService); ZEPHIR_OBS_VAR(handlers); zephir_read_property_this(&handlers, this_ptr, SL("_handlers"), PH_NOISY_CC); if (Z_TYPE_P(handlers) == IS_ARRAY) { ZEPHIR_OBS_VAR(controllerSuffix); zephir_read_property_this(&controllerSuffix, this_ptr, SL("_controllerSuffix"), PH_NOISY_CC); zephir_is_iterable(handlers, &_2, &_1, 0, 0, "phalcon/mvc/router/annotations.zep", 208); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(scope, _3); if (Z_TYPE_P(scope) == IS_ARRAY) { ZEPHIR_OBS_NVAR(prefix); zephir_array_fetch_long(&prefix, scope, 0, PH_NOISY, "phalcon/mvc/router/annotations.zep", 117 TSRMLS_CC); if (!(ZEPHIR_IS_EMPTY(prefix))) { if (!(zephir_start_with(realUri, prefix, NULL))) { continue; } } if (Z_TYPE_P(annotationsService) != IS_OBJECT) { _4 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _4); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "A dependency injection container is required to access the 'annotations' service", "phalcon/mvc/router/annotations.zep", 129); return; } ZEPHIR_INIT_NVAR(_5); ZVAL_STRING(_5, "annotations", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&annotationsService, dependencyInjector, "getshared", &_6, _5); zephir_check_temp_parameter(_5); zephir_check_call_status(); } ZEPHIR_OBS_NVAR(handler); zephir_array_fetch_long(&handler, scope, 1, PH_NOISY, "phalcon/mvc/router/annotations.zep", 138 TSRMLS_CC); if (zephir_memnstr_str(handler, SL("\\"), "phalcon/mvc/router/annotations.zep", 140)) { ZEPHIR_INIT_NVAR(controllerName); zephir_get_class_ns(controllerName, handler, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(lowerControllerName); zephir_uncamelize(lowerControllerName, controllerName); ZEPHIR_INIT_NVAR(namespaceName); zephir_get_ns_class(namespaceName, handler, 0 TSRMLS_CC); } else { ZEPHIR_CPY_WRT(controllerName, handler); ZEPHIR_INIT_NVAR(lowerControllerName); zephir_uncamelize(lowerControllerName, controllerName); ZEPHIR_INIT_NVAR(namespaceName); ZVAL_NULL(namespaceName); } zephir_update_property_this(this_ptr, SL("_routePrefix"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); ZEPHIR_OBS_NVAR(moduleName); zephir_array_isset_long_fetch(&moduleName, scope, 2, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(sufixed); ZEPHIR_CONCAT_VV(sufixed, handler, controllerSuffix); ZEPHIR_CALL_METHOD(&handlerAnnotations, annotationsService, "get", NULL, sufixed); zephir_check_call_status(); if (Z_TYPE_P(handlerAnnotations) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&classAnnotations, handlerAnnotations, "getclassannotations", NULL); zephir_check_call_status(); if (Z_TYPE_P(classAnnotations) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&annotations, classAnnotations, "getannotations", NULL); zephir_check_call_status(); if (Z_TYPE_P(annotations) == IS_ARRAY) { zephir_is_iterable(annotations, &_8, &_7, 0, 0, "phalcon/mvc/router/annotations.zep", 187); for ( ; zephir_hash_get_current_data_ex(_8, (void**) &_9, &_7) == SUCCESS ; zephir_hash_move_forward_ex(_8, &_7) ) { ZEPHIR_GET_HVALUE(annotation, _9); ZEPHIR_CALL_METHOD(NULL, this_ptr, "processcontrollerannotation", &_10, controllerName, annotation); zephir_check_call_status(); } } } ZEPHIR_CALL_METHOD(&methodAnnotations, handlerAnnotations, "getmethodsannotations", NULL); zephir_check_call_status(); if (Z_TYPE_P(methodAnnotations) == IS_ARRAY) { ZEPHIR_INIT_NVAR(lowercased); zephir_uncamelize(lowercased, handler); zephir_is_iterable(methodAnnotations, &_12, &_11, 0, 0, "phalcon/mvc/router/annotations.zep", 203); for ( ; zephir_hash_get_current_data_ex(_12, (void**) &_13, &_11) == SUCCESS ; zephir_hash_move_forward_ex(_12, &_11) ) { ZEPHIR_GET_HMKEY(method, _12, _11); ZEPHIR_GET_HVALUE(collection, _13); if (Z_TYPE_P(collection) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&_14, collection, "getannotations", NULL); zephir_check_call_status(); zephir_is_iterable(_14, &_16, &_15, 0, 0, "phalcon/mvc/router/annotations.zep", 201); for ( ; zephir_hash_get_current_data_ex(_16, (void**) &_17, &_15) == SUCCESS ; zephir_hash_move_forward_ex(_16, &_15) ) { ZEPHIR_GET_HVALUE(annotation, _17); ZEPHIR_CALL_METHOD(NULL, this_ptr, "processactionannotation", &_18, moduleName, namespaceName, lowerControllerName, method, annotation); zephir_check_call_status(); } } } } } } } } zephir_update_property_this(this_ptr, SL("_processed"), (1) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } ZEPHIR_CALL_PARENT(NULL, phalcon_mvc_router_annotations_ce, this_ptr, "handle", &_19, realUri); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); }
/** * Lists table references * * @param string $table * @param string $schema * @return Phalcon\Db\Reference[] */ PHP_METHOD(Phalcon_Db_Adapter_Pdo_Sqlite, describeReferences){ zval *table = NULL, *schema = NULL, *dialect = NULL, *sql = NULL, *empty_arr = NULL, *references = NULL; zval *fetch_assoc = NULL, *describe = NULL, *reference = NULL, *constraint_name = NULL, *constraint_id = NULL; zval *referenced_schema = NULL, *referenced_table = NULL; zval *reference_array = NULL, *column_name = NULL, *referenced_columns = NULL; zval *reference_objects = NULL, *array_reference = NULL; zval *name = NULL, *columns = NULL, *definition = NULL; zval *t0 = NULL, *t1 = NULL, *t2 = NULL, *t3 = NULL; HashTable *ah0, *ah1; HashPosition hp0, hp1; zval **hd; char *hash_index; uint hash_index_len; ulong hash_num; int hash_type; 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(dialect); phalcon_read_property(&dialect, this_ptr, SL("_dialect"), PH_NOISY_CC); PHALCON_INIT_VAR(sql); PHALCON_CALL_METHOD_PARAMS_2(sql, dialect, "describereferences", table, schema, PH_NO_CHECK); PHALCON_INIT_VAR(empty_arr); array_init(empty_arr); PHALCON_INIT_VAR(references); array_init(references); 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); 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(reference); PHALCON_INIT_VAR(constraint_id); PHALCON_INIT_VAR(constraint_name); phalcon_array_fetch_string(&constraint_id, reference, SL("id"), PH_NOISY_CC); PHALCON_CONCAT_SV(constraint_name, "foreign_key_", constraint_id); eval_int = phalcon_array_isset(references, constraint_name); if (!eval_int) { PHALCON_INIT_VAR(referenced_schema); ZVAL_STRING(referenced_schema, "main", 1); PHALCON_INIT_VAR(referenced_table); phalcon_array_fetch_string(&referenced_table, reference, SL("table"), PH_NOISY_CC); PHALCON_INIT_VAR(reference_array); array_init(reference_array); phalcon_array_update_string(&reference_array, SL("referencedSchema"), &referenced_schema, PH_COPY | PH_SEPARATE TSRMLS_CC); phalcon_array_update_string(&reference_array, SL("referencedTable"), &referenced_table, PH_COPY | PH_SEPARATE TSRMLS_CC); phalcon_array_update_string(&reference_array, SL("columns"), &empty_arr, PH_COPY | PH_SEPARATE TSRMLS_CC); phalcon_array_update_string(&reference_array, SL("referencedColumns"), &empty_arr, PH_COPY | PH_SEPARATE TSRMLS_CC); phalcon_array_update_zval(&references, constraint_name, &reference_array, PH_COPY | PH_SEPARATE TSRMLS_CC); } PHALCON_INIT_VAR(column_name); phalcon_array_fetch_string(&column_name, reference, SL("from"), PH_NOISY_CC); if (Z_TYPE_P(references) == IS_ARRAY) { PHALCON_INIT_VAR(t0); phalcon_array_fetch(&t0, references, constraint_name, PH_SILENT_CC); } if (Z_REFCOUNT_P(t0) > 1) { phalcon_array_update_zval(&references, constraint_name, &t0, PH_COPY | PH_CTOR TSRMLS_CC); } if (Z_TYPE_P(t0) != IS_ARRAY) { convert_to_array(t0); phalcon_array_update_zval(&references, constraint_name, &t0, PH_COPY TSRMLS_CC); } if (Z_TYPE_P(t0) == IS_ARRAY) { PHALCON_INIT_VAR(t1); phalcon_array_fetch_string(&t1, t0, SL("columns"), PH_SILENT_CC); } if (Z_REFCOUNT_P(t1) > 1) { phalcon_array_update_string(&t0, SL("columns"), &t1, PH_COPY | PH_CTOR TSRMLS_CC); } if (Z_TYPE_P(t1) != IS_ARRAY) { convert_to_array(t1); phalcon_array_update_string(&t0, SL("columns"), &t1, PH_COPY TSRMLS_CC); } phalcon_array_append(&t1, column_name, 0 TSRMLS_CC); PHALCON_INIT_VAR(referenced_columns); phalcon_array_fetch_string(&referenced_columns, reference, SL("to"), PH_NOISY_CC); if (Z_TYPE_P(references) == IS_ARRAY) { PHALCON_INIT_VAR(t2); phalcon_array_fetch(&t2, references, constraint_name, PH_SILENT_CC); } if (Z_REFCOUNT_P(t2) > 1) { phalcon_array_update_zval(&references, constraint_name, &t2, PH_COPY | PH_CTOR TSRMLS_CC); } if (Z_TYPE_P(t2) != IS_ARRAY) { convert_to_array(t2); phalcon_array_update_zval(&references, constraint_name, &t2, PH_COPY TSRMLS_CC); } if (Z_TYPE_P(t2) == IS_ARRAY) { PHALCON_INIT_VAR(t3); phalcon_array_fetch_string(&t3, t2, SL("referencedColumns"), PH_SILENT_CC); } if (Z_REFCOUNT_P(t3) > 1) { phalcon_array_update_string(&t2, SL("referencedColumns"), &t3, PH_COPY | PH_CTOR TSRMLS_CC); } if (Z_TYPE_P(t3) != IS_ARRAY) { convert_to_array(t3); phalcon_array_update_string(&t2, SL("referencedColumns"), &t3, PH_COPY TSRMLS_CC); } phalcon_array_append(&t3, referenced_columns, 0 TSRMLS_CC); zend_hash_move_forward_ex(ah0, &hp0); goto ph_cycle_start_0; ph_cycle_end_0: PHALCON_INIT_VAR(reference_objects); array_init(reference_objects); if (!phalcon_valid_foreach(references TSRMLS_CC)) { return; } ah1 = Z_ARRVAL_P(references); zend_hash_internal_pointer_reset_ex(ah1, &hp1); ph_cycle_start_1: if(zend_hash_get_current_data_ex(ah1, (void**) &hd, &hp1) != SUCCESS){ goto ph_cycle_end_1; } PHALCON_INIT_VAR(name); PHALCON_GET_FOREACH_KEY(name, ah1, hp1); PHALCON_GET_FOREACH_VALUE(array_reference); PHALCON_INIT_VAR(referenced_schema); phalcon_array_fetch_string(&referenced_schema, array_reference, SL("referencedSchema"), PH_NOISY_CC); PHALCON_INIT_VAR(referenced_table); phalcon_array_fetch_string(&referenced_table, array_reference, SL("referencedTable"), PH_NOISY_CC); PHALCON_INIT_VAR(columns); phalcon_array_fetch_string(&columns, array_reference, SL("columns"), PH_NOISY_CC); PHALCON_INIT_VAR(referenced_columns); phalcon_array_fetch_string(&referenced_columns, array_reference, SL("referencedColumns"), PH_NOISY_CC); PHALCON_INIT_VAR(definition); array_init(definition); phalcon_array_update_string(&definition, SL("referencedSchema"), &referenced_schema, PH_COPY | PH_SEPARATE TSRMLS_CC); phalcon_array_update_string(&definition, SL("referencedTable"), &referenced_table, PH_COPY | PH_SEPARATE TSRMLS_CC); phalcon_array_update_string(&definition, SL("columns"), &columns, PH_COPY | PH_SEPARATE TSRMLS_CC); phalcon_array_update_string(&definition, SL("referencedColumns"), &referenced_columns, PH_COPY | PH_SEPARATE TSRMLS_CC); PHALCON_INIT_VAR(reference); object_init_ex(reference, phalcon_db_reference_ce); PHALCON_CALL_METHOD_PARAMS_2_NORETURN(reference, "__construct", name, definition, PH_CHECK); phalcon_array_update_zval(&reference_objects, name, &reference, PH_COPY | PH_SEPARATE TSRMLS_CC); zend_hash_move_forward_ex(ah1, &hp1); goto ph_cycle_start_1; ph_cycle_end_1: RETURN_CTOR(reference_objects);}
/* {{{ schemaTypeInfo DOMTypeInfo readonly=yes URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Attr-schemaTypeInfo Since: DOM Level 3 */ int dom_attr_schema_type_info_read(dom_object *obj, zval *retval) { php_error_docref(NULL, E_WARNING, "Not yet implemented"); ZVAL_NULL(retval); return SUCCESS; }
/* {{{ ps_fetch_null */ static void ps_fetch_null(zval *zv, const MYSQLND_FIELD * const field, const unsigned int pack_len, const zend_uchar ** row) { ZVAL_NULL(zv); }
static void call_php(char *name, PARAMDSC *r, int argc, PARAMDSC **argv) { do { zval callback, args[4], return_value; PARAMVARY *res = (PARAMVARY*)r->dsc_address; int i; ZVAL_STRING(&callback, name); LOCK(); /* check if the requested function exists */ if (!zend_is_callable(&callback, 0, NULL TSRMLS_CC)) { break; } UNLOCK(); /* create the argument array */ for (i = 0; i < argc; ++i) { /* test arg for null */ if (argv[i]->dsc_flags & DSC_null) { ZVAL_NULL(&args[i]); continue; } switch (argv[i]->dsc_dtype) { ISC_INT64 l; struct tm t; char const *fmt; char d[64]; case dtype_cstring: //??? ZVAL_STRING(&args[i], (char*)argv[i]->dsc_address); break; case dtype_text: //??? ZVAL_STRINGL(&args[i], (char*)argv[i]->dsc_address, argv[i]->dsc_length); break; case dtype_varying: //??? ZVAL_STRINGL(&args[i], ((PARAMVARY*)argv[i]->dsc_address)->vary_string, ((PARAMVARY*)argv[i]->dsc_address)->vary_length); break; case dtype_short: if (argv[i]->dsc_scale == 0) { ZVAL_LONG(&args[i], *(short*)argv[i]->dsc_address); } else { ZVAL_DOUBLE(&args[i], ((double)*(short*)argv[i]->dsc_address)/scales[-argv[i]->dsc_scale]); } break; case dtype_long: if (argv[i]->dsc_scale == 0) { ZVAL_LONG(&args[i], *(ISC_LONG*)argv[i]->dsc_address); } else { ZVAL_DOUBLE(&args[i], ((double)*(ISC_LONG*)argv[i]->dsc_address)/scales[-argv[i]->dsc_scale]); } break; case dtype_int64: l = *(ISC_INT64*)argv[i]->dsc_address; if (argv[i]->dsc_scale == 0 && l <= LONG_MAX && l >= LONG_MIN) { ZVAL_LONG(&args[i], (long)l); } else { ZVAL_DOUBLE(&args[i], ((double)l)/scales[-argv[i]->dsc_scale]); } break; case dtype_real: ZVAL_DOUBLE(&args[i], *(float*)argv[i]->dsc_address); break; case dtype_double: ZVAL_DOUBLE(&args[i], *(double*)argv[i]->dsc_address); break; case dtype_sql_date: isc_decode_sql_date((ISC_DATE*)argv[i]->dsc_address, &t); ZVAL_STRINGL(&args[i], d, strftime(d, sizeof(d), INI_STR("ibase.dateformat"), &t),1); break; case dtype_sql_time: isc_decode_sql_time((ISC_TIME*)argv[i]->dsc_address, &t); ZVAL_STRINGL(&args[i], d, strftime(d, sizeof(d), INI_STR("ibase.timeformat"), &t),1); break; case dtype_timestamp: isc_decode_timestamp((ISC_TIMESTAMP*)argv[i]->dsc_address, &t); ZVAL_STRINGL(&args[i], d, strftime(d, sizeof(d), INI_STR("ibase.timestampformat"), &t)); break; } } LOCK(); /* now call the function */ if (FAILURE == call_user_function(EG(function_table), NULL, &callback, &return_value, argc, args TSRMLS_CC)) { UNLOCK(); break; } UNLOCK(); for (i = 0; i < argc; ++i) { switch (argv[i]->dsc_dtype) { case dtype_sql_date: case dtype_sql_time: case dtype_timestamp: zval_dtor(&args[i]); } } zval_dtor(&callback); /* return whatever type we got back from the callback: let DB handle conversion */ switch (Z_TYPE(return_value)) { case IS_LONG: r->dsc_dtype = dtype_long; *(long*)r->dsc_address = Z_LVAL(return_value); r->dsc_length = sizeof(long); break; case IS_DOUBLE: r->dsc_dtype = dtype_double; *(double*)r->dsc_address = Z_DVAL(return_value); r->dsc_length = sizeof(double); break; case IS_NULL: r->dsc_flags |= DSC_null; break; default: convert_to_string(&return_value); case IS_STRING: r->dsc_dtype = dtype_varying; memcpy(res->vary_string, Z_STRVAL(return_value), (res->vary_length = min(r->dsc_length-2,Z_STRLEN(return_value)))); r->dsc_length = res->vary_length+2; break; } zval_dtor(&return_value); return; } while (0); /** * If we end up here, we should report an error back to the DB engine, but * that's not possible. We can however report it back to PHP. */ LOCK(); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error calling function '%s' from database", name); UNLOCK(); }
static zval *saproxy_read_dimension(zend_object *object, zval *offset, int type, zval *rv) { php_com_saproxy *proxy = (php_com_saproxy*) object; UINT dims, i; SAFEARRAY *sa; LONG ubound, lbound; HRESULT res; ZVAL_NULL(rv); if (V_VT(&proxy->obj->v) == VT_DISPATCH) { VARIANT v; zval *args; /* prop-get using first dimension as the property name, * all subsequent dimensions and the offset as parameters */ args = safe_emalloc(proxy->dimensions + 1, sizeof(zval), 0); for (i = 1; i < (UINT) proxy->dimensions; i++) { args[i-1] = proxy->indices[i]; } ZVAL_COPY_VALUE(&args[i-1], offset); convert_to_string(&proxy->indices[0]); VariantInit(&v); res = php_com_do_invoke(proxy->obj, Z_STRVAL(proxy->indices[0]), Z_STRLEN(proxy->indices[0]), DISPATCH_METHOD|DISPATCH_PROPERTYGET, &v, proxy->dimensions, args, 0); if (res == SUCCESS) { php_com_zval_from_variant(rv, &v, proxy->obj->code_page); VariantClear(&v); } else if (res == DISP_E_BADPARAMCOUNT) { /* return another proxy */ php_com_saproxy_create(object, rv, offset); } return rv; } else if (!V_ISARRAY(&proxy->obj->v)) { php_com_throw_exception(E_INVALIDARG, "invalid read from com proxy object"); return rv; } /* the SafeArray case */ /* offset/index must be an integer */ convert_to_long(offset); sa = V_ARRAY(&proxy->obj->v); dims = SafeArrayGetDim(sa); if ((UINT) proxy->dimensions >= dims) { /* too many dimensions */ php_com_throw_exception(E_INVALIDARG, "too many dimensions!"); return rv; } /* bounds check */ SafeArrayGetLBound(sa, proxy->dimensions, &lbound); SafeArrayGetUBound(sa, proxy->dimensions, &ubound); if (Z_LVAL_P(offset) < lbound || Z_LVAL_P(offset) > ubound) { php_com_throw_exception(DISP_E_BADINDEX, "index out of bounds"); return rv; } if (dims - 1 == proxy->dimensions) { LONG *indices; VARTYPE vt; VARIANT v; VariantInit(&v); /* we can return a real value */ indices = safe_emalloc(dims, sizeof(LONG), 0); /* copy indices from proxy */ for (i = 0; i < dims; i++) { convert_to_long(&proxy->indices[i]); indices[i] = (LONG)Z_LVAL(proxy->indices[i]); } /* add user-supplied index */ indices[dims-1] = (LONG)Z_LVAL_P(offset); /* now fetch the value */ if (FAILED(SafeArrayGetVartype(sa, &vt)) || vt == VT_EMPTY) { vt = V_VT(&proxy->obj->v) & ~VT_ARRAY; } if (vt == VT_VARIANT) { res = SafeArrayGetElement(sa, indices, &v); } else { V_VT(&v) = vt; res = SafeArrayGetElement(sa, indices, &v.lVal); } efree(indices); if (SUCCEEDED(res)) { php_com_wrap_variant(rv, &v, proxy->obj->code_page); } else { php_com_throw_exception(res, NULL); } VariantClear(&v); } else { /* return another proxy */ php_com_saproxy_create(object, rv, offset); } return rv; }