コード例 #1
0
ファイル: enum.zep.c プロジェクト: wells5609/xpl
/**
 * Validates a value against the class constants.
 *
 * If value is a valid constant name, returns the corresponding value.
 *
 * If value is null and a default is set, returns the default value.
 *
 * @param mixed value
 *
 * @return mixed
 *
 * @throws \RuntimeException if value is null and no default exists, or if given an invalid value.
 */
PHP_METHOD(Xpl_Enum, filterValidateValue) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *value = NULL, *reflection = NULL, *constants = NULL, *_0, *_2 = NULL, *_1$$6;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 0, 1, &value);

	if (!value) {
		ZEPHIR_CPY_WRT(value, ZEPHIR_GLOBAL(global_null));
	} else {
		ZEPHIR_SEPARATE_PARAM(value);
	}


	ZEPHIR_INIT_VAR(reflection);
	object_init_ex(reflection, zephir_get_internal_ce(SS("reflectionclass") TSRMLS_CC));
	ZEPHIR_INIT_VAR(_0);
	zephir_get_class(_0, this_ptr, 0 TSRMLS_CC);
	ZEPHIR_CALL_METHOD(NULL, reflection, "__construct", NULL, 63, _0);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(&constants, reflection, "getconstants", NULL, 100);
	zephir_check_call_status();
	if (Z_TYPE_P(value) == IS_NULL) {
		ZEPHIR_OBS_NVAR(value);
		if (zephir_array_isset_string_fetch(&value, constants, SS("_default"), 0 TSRMLS_CC)) {
			RETVAL_ZVAL(value, 1, 0);
			RETURN_MM();
		}
		ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_RuntimeException, "Missing value: no default exists", "xpl/enum.zep", 177);
		return;
	}
	if (Z_TYPE_P(value) == IS_STRING) {
		if (zephir_array_isset(constants, value)) {
			zephir_array_fetch(&_1$$6, constants, value, PH_NOISY | PH_READONLY, "xpl/enum.zep", 183 TSRMLS_CC);
			ZEPHIR_CPY_WRT(value, _1$$6);
		}
		if ((zephir_method_exists(this_ptr, value TSRMLS_CC)  == SUCCESS)) {
			ZEPHIR_RETURN_CALL_METHOD_ZVAL(this_ptr, value, NULL, 0);
			zephir_check_call_status();
			RETURN_MM();
		}
	}
	ZEPHIR_CALL_FUNCTION(&_2, "in_array", NULL, 2, value, constants, ZEPHIR_GLOBAL(global_true));
	zephir_check_call_status();
	if (!(zephir_is_true(_2))) {
		ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_RuntimeException, "Invalid enum value", "xpl/enum.zep", 193);
		return;
	}
	RETVAL_ZVAL(value, 1, 0);
	RETURN_MM();

}
コード例 #2
0
ファイル: yaf_closure.c プロジェクト: ruolinn/yaf
/*
 * This is PHP code snippet handling extend()s calls :

 $extended = function ($c) use ($callable, $factory) {
 return $callable($factory($c), $c);
 };

*/
PHP_METHOD(PimpleClosure, invoker)
{
	zval *arg = NULL, retval = {0}, newretval = {0};
	zend_fcall_info fci      = {0};
	zval args[2];
	FETCH_CUSTOM_OBJ_THIS(pimple_closure_object)

    if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &arg) == FAILURE) {
      OBJ_RELEASE((zend_object*)execute_data->func->common.prototype);
      return;
    }

	ZVAL_COPY_VALUE(&args[0], arg);
	fci.function_name = obj->factory;
	fci.params        = args;
	fci.param_count   = 1;
	fci.retval        = &retval;
	fci.size = sizeof(fci);

	if (zend_call_function(&fci, NULL) == FAILURE || EG(exception)) {
		OBJ_RELEASE((zend_object*)execute_data->func->common.prototype);
		RETVAL_ZVAL(&EG(uninitialized_zval), 1, 0);
		return;
	}

	memset(&fci, 0, sizeof(fci));
	fci.size = sizeof(fci);

	ZVAL_COPY_VALUE(&args[0], &retval);
	ZVAL_COPY_VALUE(&args[1], arg);

	fci.function_name = obj->callable;
	fci.params        = args;
	fci.param_count   = 2;
	fci.retval = &newretval;

	if (zend_call_function(&fci, NULL) == FAILURE || EG(exception)) {
		zval_ptr_dtor(&retval);
		OBJ_RELEASE((zend_object*)execute_data->func->common.prototype);
		RETVAL_ZVAL(&EG(uninitialized_zval), 1, 0);
		return;
	}

	zval_ptr_dtor(&retval);

	RETVAL_ZVAL(&newretval, 0 ,0);
	OBJ_RELEASE((zend_object*)execute_data->func->common.prototype);
}
コード例 #3
0
/* {{{ MongoDate::toDateTime()
 * Returns a DateTime object with the same information as the MongoDate object */
PHP_METHOD(MongoDate, toDateTime)
{
	mongo_date *date;
	int64_t     sec;
	int64_t     usec;
	double      dusec;
	char       *str;
	int         str_len;
	zval        datetime_object;
	php_date_obj *datetime_obj;
	zval *datetime_object_ptr = &datetime_object;

	date = (mongo_date*) zend_object_store_get_object(getThis() TSRMLS_CC);

	php_date_instantiate(php_date_get_date_ce(), &datetime_object TSRMLS_CC);
	mongo_date_to_parts(date, &sec, &usec, &dusec);

#ifdef WIN32
	str_len = spprintf(&str, 0, "@%I64d", (int64_t) sec);
#else
	str_len = spprintf(&str, 0, "@%lld", (long long int) sec);
#endif

	datetime_obj = zend_object_store_get_object(&datetime_object TSRMLS_CC);
	php_date_initialize(datetime_obj, str, str_len, NULL, NULL, 0 TSRMLS_CC);
	efree(str);
	datetime_obj->time->f = dusec;

	RETVAL_ZVAL(datetime_object_ptr, 0, 0);
}
コード例 #4
0
PHP_METHOD(MongoDB, repair)
{
	zend_bool cloned=0, original=0;
	zval *cmd, *retval;
	mongo_db *db;

	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|bb", &cloned, &original) == FAILURE) {
		return;
	}

	PHP_MONGO_GET_DB(getThis());

	MAKE_STD_ZVAL(cmd);
	array_init(cmd);
	add_assoc_long(cmd, "repairDatabase", 1);
	add_assoc_bool(cmd, "preserveClonedFilesOnFailure", cloned);
	add_assoc_bool(cmd, "backupOriginalFiles", original);

	retval = php_mongo_runcommand(db->link, &db->read_pref, Z_STRVAL_P(db->name), Z_STRLEN_P(db->name), cmd, NULL, 0, NULL TSRMLS_CC);

	zval_ptr_dtor(&cmd);

	if (retval) {
		RETVAL_ZVAL(retval, 0, 1);
	}
}
コード例 #5
0
ファイル: memory.c プロジェクト: 100851766/cphalcon
/**
 * Returns a cached content
 *
 * @param 	string $keyName
 * @param   long $lifetime
 * @return  mixed
 */
PHP_METHOD(Phalcon_Cache_Backend_Memory, get){

	zval *key_name, *lifetime = NULL;
	zval *data, *cached_content, *frontend, *last_key;

	PHALCON_MM_GROW();

	phalcon_fetch_params(1, 1, 1, &key_name, &lifetime);
	
	if (Z_TYPE_P(key_name) == IS_NULL) {
		last_key = phalcon_fetch_nproperty_this(this_ptr, SL("_lastKey"), PH_NOISY TSRMLS_CC);
	} else {
		zval *prefix = phalcon_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY TSRMLS_CC);
	
		PHALCON_INIT_VAR(last_key);
		PHALCON_CONCAT_VV(last_key, prefix, key_name);
		phalcon_update_property_this(this_ptr, SL("_lastKey"), last_key TSRMLS_CC);
	}
	
	data = phalcon_fetch_nproperty_this(this_ptr, SL("_data"), PH_NOISY TSRMLS_CC);
	if (phalcon_array_isset_fetch(&cached_content, data, last_key)) {
		if (Z_TYPE_P(cached_content) != IS_NULL) {
			if (phalcon_is_numeric(cached_content)) {
				RETVAL_ZVAL(cached_content, 1, 0);
			} else {
				frontend = phalcon_fetch_nproperty_this(this_ptr, SL("_frontend"), PH_NOISY TSRMLS_CC);
				PHALCON_RETURN_CALL_METHOD(frontend, "afterretrieve", cached_content);
			}
		}
	}

	PHALCON_MM_RESTORE();
}
コード例 #6
0
ファイル: debug.zep.c プロジェクト: flaver12/cphalcon
/**
 * Escapes a string with htmlentities
 */
PHP_METHOD(Phalcon_Debug, _escapeString) {

	int ZEPHIR_LAST_CALL_STATUS;
	zephir_nts_static zephir_fcall_cache_entry *_5 = NULL;
	zval *value, *_0, _1, _2, _3, _4;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &value);



	if (Z_TYPE_P(value) == IS_STRING) {
		ZEPHIR_INIT_VAR(_0);
		ZEPHIR_SINIT_VAR(_1);
		ZVAL_STRING(&_1, "\n", 0);
		ZEPHIR_SINIT_VAR(_2);
		ZVAL_STRING(&_2, "\\n", 0);
		zephir_fast_str_replace(&_0, &_1, &_2, value TSRMLS_CC);
		ZEPHIR_SINIT_VAR(_3);
		ZVAL_LONG(&_3, 2);
		ZEPHIR_SINIT_VAR(_4);
		ZVAL_STRING(&_4, "utf-8", 0);
		ZEPHIR_RETURN_CALL_FUNCTION("htmlentities", &_5, _0, &_3, &_4);
		zephir_check_call_status();
		RETURN_MM();
	}
	RETVAL_ZVAL(value, 1, 0);
	RETURN_MM();

}
コード例 #7
0
ファイル: bucket.c プロジェクト: radev/php_riak
/* {{{ proto Riak\BucketPropertyList Riak\Bucket->getPropertyList()
Fetch and return a RiakBucketProperties object with properties for this bucket */
PHP_METHOD(RiakBucket, getPropertyList)
{
    riak_connection *connection;
    RIACK_STRING bucketName;
    uint32_t nVal = 3;
    uint8_t allowMult = 0;
    int riackResult;
    zval *zBucketProps, *zAllowMult, *zNVal;

    GET_RIAK_CONNECTION_RETURN_EXC_ON_ERROR(connection)

    bucketName = riack_name_from_bucket(getThis() TSRMLS_CC);
    riackResult = riack_get_bucket_props(connection->client,  bucketName, &nVal, &allowMult);

    CHECK_RIACK_STATUS_THROW_AND_RETURN_ON_ERROR(connection, riackResult);

    MAKE_STD_ZVAL(zNVal);
    ZVAL_LONG(zNVal, nVal);

    MAKE_STD_ZVAL(zAllowMult);
    ZVAL_BOOL(zAllowMult, allowMult);

    MAKE_STD_ZVAL(zBucketProps);
    object_init_ex(zBucketProps, riak_bucket_properties_ce);
    RIAK_CALL_METHOD2(RiakBucketProperties, __construct, zBucketProps, zBucketProps, zNVal, zAllowMult);
    RETVAL_ZVAL(zBucketProps, 0, 1);

    zval_ptr_dtor(&zNVal);
    zval_ptr_dtor(&zAllowMult);
}
コード例 #8
0
ファイル: validator.zep.c プロジェクト: AlloVince/cphalcon
/**
 * Returns an option
 */
PHP_METHOD(Phalcon_Mvc_Model_Validator, getOption) {

	zval *option_param = NULL, *defaultValue = NULL, *options, *value;
	zval *option = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &option_param, &defaultValue);

	if (unlikely(Z_TYPE_P(option_param) != IS_STRING && Z_TYPE_P(option_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'option' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (likely(Z_TYPE_P(option_param) == IS_STRING)) {
		zephir_get_strval(option, option_param);
	} else {
		ZEPHIR_INIT_VAR(option);
		ZVAL_EMPTY_STRING(option);
	}
	if (!defaultValue) {
		ZEPHIR_INIT_VAR(defaultValue);
		ZVAL_STRING(defaultValue, "", 1);
	}


	options = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC);
	if (zephir_array_isset_fetch(&value, options, option, 1 TSRMLS_CC)) {
		RETURN_CTOR(value);
	}
	RETVAL_ZVAL(defaultValue, 1, 0);
	RETURN_MM();

}
コード例 #9
0
ファイル: debug.c プロジェクト: Myleft/cphalcon
PHP_METHOD(Phalcon_Debug, getFileLink) {

	zval **file, **line, **format;

	phalcon_fetch_params_ex(3, 0, &file, &line, &format);

	PHALCON_ENSURE_IS_STRING(file);
	PHALCON_ENSURE_IS_STRING(line);

	if (Z_TYPE_PP(format) == IS_STRING) {
		char *tmp, *link;
		int tmp_len, link_len;
		zval z_link = zval_used_for_init;

		tmp  = php_str_to_str_ex(Z_STRVAL_PP(format), Z_STRLEN_PP(format), SL("%f"), Z_STRVAL_PP(file), Z_STRLEN_PP(file), &tmp_len, 1, NULL);
		link = php_str_to_str_ex(tmp, tmp_len, SL("%l"), Z_STRVAL_PP(line), Z_STRLEN_PP(line), &link_len, 1, NULL);

		ZVAL_STRINGL(&z_link, link, link_len, 0);

		efree(tmp);
		PHALCON_CONCAT_SVSVS(return_value, "<a href=\"", &z_link, "\">", *file, "</a>");
		efree(link);
	}
	else {
		RETVAL_ZVAL(*file, 1, 0);
	}
}
コード例 #10
0
/**
 * Get an action parameter
 *
 * @param string $key
 * @param mixed $default Default value to use if key not found
 * @return mixed
 */
PHP_METHOD(Yaf_Request_Abstract, getParam) {

	zval *_0 = NULL;
	zval *name = NULL, *tmpDefault = NULL, *_1, *_2, *_3;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &name, &tmpDefault);

	ZEPHIR_SEPARATE_PARAM(name);
	if (!tmpDefault) {
		tmpDefault = ZEPHIR_GLOBAL(global_null);
	}


	zephir_get_strval(_0, name);
	ZEPHIR_CPY_WRT(name, _0);
	_1 = zephir_fetch_nproperty_this(this_ptr, SL("params"), PH_NOISY_CC);
	if (zephir_array_isset(_1, name)) {
		_2 = zephir_fetch_nproperty_this(this_ptr, SL("params"), PH_NOISY_CC);
		zephir_array_fetch(&_3, _2, name, PH_NOISY | PH_READONLY, "yaf/request_abstract.zep", 196 TSRMLS_CC);
		RETURN_CTOR(_3);
	}
	RETVAL_ZVAL(tmpDefault, 1, 0);
	RETURN_MM();

}
コード例 #11
0
ファイル: mysql.zep.c プロジェクト: 3axap4eHko/cphalcon
/**
 * Escapes a column/table/schema name
 *
 * @param string|array identifier
 * @return string
 */
PHP_METHOD(Phalcon_Db_Adapter_Pdo_Mysql, escapeIdentifier) {

	zval *identifier, *domain, *name;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &identifier);



	if (Z_TYPE_P(identifier) == IS_ARRAY) {
		ZEPHIR_OBS_VAR(domain);
		zephir_array_fetch_long(&domain, identifier, 0, PH_NOISY, "phalcon/db/adapter/pdo/mysql.zep", 63 TSRMLS_CC);
		ZEPHIR_OBS_VAR(name);
		zephir_array_fetch_long(&name, identifier, 1, PH_NOISY, "phalcon/db/adapter/pdo/mysql.zep", 64 TSRMLS_CC);
		if (ZEPHIR_GLOBAL(db).escape_identifiers) {
			ZEPHIR_CONCAT_SVSVS(return_value, "`", domain, "`.`", name, "`");
			RETURN_MM();
		}
		ZEPHIR_CONCAT_VSV(return_value, domain, ".", name);
		RETURN_MM();
	}
	if (ZEPHIR_GLOBAL(db).escape_identifiers) {
		ZEPHIR_CONCAT_SVS(return_value, "`", identifier, "`");
		RETURN_MM();
	}
	RETVAL_ZVAL(identifier, 1, 0);
	RETURN_MM();

}
コード例 #12
0
ファイル: config.zep.c プロジェクト: spuy767/cphalcon
/**
 * Gets an attribute from the configuration, if the attribute isn't defined returns null
 * If the value is exactly null or is not defined the default value will be used instead
 *
 *<code>
 * echo $config->get('controllersDir', '../app/controllers/');
 *</code>
 */
PHP_METHOD(Phalcon_Config, get) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *index = NULL, *defaultValue = NULL, *_0 = NULL, *_1;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &index, &defaultValue);

	ZEPHIR_SEPARATE_PARAM(index);
	if (!defaultValue) {
		defaultValue = ZEPHIR_GLOBAL(global_null);
	}


	ZEPHIR_CALL_FUNCTION(&_0, "strval", NULL, 20, index);
	zephir_check_call_status();
	ZEPHIR_CPY_WRT(index, _0);
	if (zephir_isset_property_zval(this_ptr, index TSRMLS_CC)) {
		ZEPHIR_OBS_VAR(_1);
		zephir_read_property_zval(&_1, this_ptr, index, PH_NOISY_CC);
		RETURN_CCTOR(_1);
	}
	RETVAL_ZVAL(defaultValue, 1, 0);
	RETURN_MM();

}
コード例 #13
0
ファイル: validation.zep.c プロジェクト: SDpower/cphalcon
/**
 * Get label for field
 *
 * @param string field
 * @return string
 */
PHP_METHOD(Phalcon_Validation, getLabel) {

	zend_bool _0;
	zval *field, *labels = NULL, *value = NULL;

	zephir_fetch_params(0, 1, 0, &field);



	labels = zephir_fetch_nproperty_this(this_ptr, SL("_labels"), PH_NOISY_CC);
	_0 = Z_TYPE_P(labels) == IS_ARRAY;
	if (_0) {
		_0 = Z_TYPE_P(field) != IS_ARRAY;
	}
	if (_0) {
		if (zephir_array_isset_fetch(&value, labels, field, 1 TSRMLS_CC)) {
			RETURN_CTORW(value);
		}
	} else if (Z_TYPE_P(field) == IS_ARRAY) {
		zephir_fast_join_str(return_value, SL(", "), field TSRMLS_CC);
		return;
	}
	RETVAL_ZVAL(field, 1, 0);
	return;

}
コード例 #14
0
ファイル: db.c プロジェクト: cockatoo-org/mongo-php-driver
PHP_METHOD(MongoDB, setProfilingLevel) {
  long level;
  zval *data, *cmd_return;
  zval **ok;

  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &level) == FAILURE) {
    return;
  }

  MAKE_STD_ZVAL(data);
  array_init(data);
  add_assoc_long(data, "profile", level);

  MAKE_STD_ZVAL(cmd_return);
  MONGO_CMD(cmd_return, getThis());

  zval_ptr_dtor(&data);

  if (EG(exception)) {
    zval_ptr_dtor(&cmd_return);
    return;
  }

  if (zend_hash_find(HASH_P(cmd_return), "ok", 3, (void**)&ok) == SUCCESS &&
      ((Z_TYPE_PP(ok) == IS_BOOL && Z_BVAL_PP(ok)) || Z_DVAL_PP(ok) == 1)) {
    zend_hash_find(HASH_P(cmd_return), "was", 4, (void**)&ok);
    RETVAL_ZVAL(*ok, 1, 0);
  }
  else {
    RETVAL_NULL();
  }
  zval_ptr_dtor(&cmd_return);
}
コード例 #15
0
ファイル: di.zep.c プロジェクト: Studentsov/cphalcon
/**
 * Sets a service using a raw Phalcon\Di\Service definition
 */
PHP_METHOD(Phalcon_Di, setRaw) {

	zval *name_param = NULL, *rawDefinition;
	zval *name = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 2, 0, &name_param, &rawDefinition);

	if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (likely(Z_TYPE_P(name_param) == IS_STRING)) {
		zephir_get_strval(name, name_param);
	} else {
		ZEPHIR_INIT_VAR(name);
		ZVAL_EMPTY_STRING(name);
	}


	zephir_update_property_array(this_ptr, SL("_services"), name, rawDefinition TSRMLS_CC);
	RETVAL_ZVAL(rawDefinition, 1, 0);
	RETURN_MM();

}
コード例 #16
0
ファイル: files.c プロジェクト: 100851766/cphalcon
/**
 * Reads meta-data from files
 *
 * @param string $key
 * @return array
 */
PHP_METHOD(Phalcon_Mvc_Model_MetaData_Files, read){

	zval **key, *meta_data_dir, *virtual_key;
	zval *path, *data = NULL;

	phalcon_fetch_params_ex(1, 0, &key);
	PHALCON_ENSURE_IS_STRING(key);

	PHALCON_MM_GROW();

	meta_data_dir = phalcon_fetch_nproperty_this(this_ptr, SL("_metaDataDir"), PH_NOISY TSRMLS_CC);
	
	PHALCON_INIT_VAR(virtual_key);
	phalcon_prepare_virtual_path_ex(virtual_key, Z_STRVAL_PP(key), Z_STRLEN_PP(key), '_' TSRMLS_CC);
	
	PHALCON_INIT_VAR(path);
	PHALCON_CONCAT_VVS(path, meta_data_dir, virtual_key, ".php");
	
	if (phalcon_file_exists(path TSRMLS_CC) == SUCCESS) {
		RETURN_MM_ON_FAILURE(phalcon_require_ret(&data, Z_STRVAL_P(path) TSRMLS_CC));
		RETVAL_ZVAL(data, 1, 1);
	}
	
	PHALCON_MM_RESTORE();
}
コード例 #17
0
ファイル: debug.zep.c プロジェクト: bschantz/cphalcon
/**
 * Escapes a string with htmlentities
 */
PHP_METHOD(Phalcon_Debug, _escapeString) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *value, *_0$$3, _1$$3, _2$$3, _3$$3, _4$$3;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &value);



	if (Z_TYPE_P(value) == IS_STRING) {
		ZEPHIR_INIT_VAR(_0$$3);
		ZEPHIR_SINIT_VAR(_1$$3);
		ZVAL_STRING(&_1$$3, "\n", 0);
		ZEPHIR_SINIT_VAR(_2$$3);
		ZVAL_STRING(&_2$$3, "\\n", 0);
		zephir_fast_str_replace(&_0$$3, &_1$$3, &_2$$3, value TSRMLS_CC);
		ZEPHIR_SINIT_VAR(_3$$3);
		ZVAL_LONG(&_3$$3, 2);
		ZEPHIR_SINIT_VAR(_4$$3);
		ZVAL_STRING(&_4$$3, "utf-8", 0);
		ZEPHIR_RETURN_CALL_FUNCTION("htmlentities", NULL, 158, _0$$3, &_3$$3, &_4$$3);
		zephir_check_call_status();
		RETURN_MM();
	}
	RETVAL_ZVAL(value, 1, 0);
	RETURN_MM();

}
コード例 #18
0
ファイル: validator.zep.c プロジェクト: AlloVince/cphalcon
/**
 * Returns an option in the validator's options
 * Returns null if the option hasn't set
 */
PHP_METHOD(Phalcon_Validation_Validator, getOption) {

	zval *key_param = NULL, *defaultValue = NULL, *options, *value;
	zval *key = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &key_param, &defaultValue);

	if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (likely(Z_TYPE_P(key_param) == IS_STRING)) {
		zephir_get_strval(key, key_param);
	} else {
		ZEPHIR_INIT_VAR(key);
		ZVAL_EMPTY_STRING(key);
	}
	if (!defaultValue) {
		defaultValue = ZEPHIR_GLOBAL(global_null);
	}


	options = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC);
	if (Z_TYPE_P(options) == IS_ARRAY) {
		if (zephir_array_isset_fetch(&value, options, key, 1 TSRMLS_CC)) {
			RETURN_CTOR(value);
		}
	}
	RETVAL_ZVAL(defaultValue, 1, 0);
	RETURN_MM();

}
コード例 #19
0
ZEND_METHOD(Closure, __invoke) /* {{{ */
{
	zend_function *func = EG(current_execute_data)->function_state.function;
	zval ***arguments;
	zval *closure_result_ptr = NULL;

	arguments = emalloc(sizeof(zval**) * ZEND_NUM_ARGS());
	if (zend_get_parameters_array_ex(ZEND_NUM_ARGS(), arguments) == FAILURE) {
		efree(arguments);
		zend_error(E_RECOVERABLE_ERROR, "Cannot get arguments for calling closure");
		RETVAL_FALSE;
	} else if (call_user_function_ex(CG(function_table), NULL, this_ptr, &closure_result_ptr, ZEND_NUM_ARGS(), arguments, 1, NULL TSRMLS_CC) == FAILURE) {
		RETVAL_FALSE;
	} else if (closure_result_ptr) {
		if (Z_ISREF_P(closure_result_ptr) && return_value_ptr) {
			if (return_value) {
				zval_ptr_dtor(&return_value);
			}
			*return_value_ptr = closure_result_ptr;
		} else {
			RETVAL_ZVAL(closure_result_ptr, 1, 1);
		}
	}
	efree(arguments);

	/* destruct the function also, then - we have allocated it in get_method */
	efree(func->internal_function.function_name);
	efree(func);
}
コード例 #20
0
/* {{{ Cassandra\Timestamp::toDateTime() */
PHP_METHOD(Timestamp, toDateTime)
{
  cassandra_timestamp *self;
  zval *datetime = NULL;
  php_date_obj *datetime_obj = NULL;
  char *str;
  int str_len;

  if (zend_parse_parameters_none() == FAILURE) {
    return;
  }

  self = PHP_CASSANDRA_GET_TIMESTAMP(getThis());

  PHP5TO7_ZVAL_MAYBE_MAKE(datetime);
  php_date_instantiate(php_date_get_date_ce(), datetime TSRMLS_CC);

#if PHP_MAJOR_VERSION >= 7
  datetime_obj = php_date_obj_from_obj(Z_OBJ_P(datetime));
#else
  datetime_obj = zend_object_store_get_object(datetime TSRMLS_CC);
#endif

  str_len      = spprintf(&str, 0, "@%ld", (long) (self->timestamp / 1000));
  php_date_initialize(datetime_obj, str, str_len, NULL, NULL, 0 TSRMLS_CC);
  efree(str);

  RETVAL_ZVAL(datetime, 0, 0);
}
コード例 #21
0
/* {{{ MongoCursor->key
 */
PHP_METHOD(MongoCursor, key) {
  zval **id;
  mongo_cursor *cursor = (mongo_cursor*)zend_object_store_get_object(getThis() TSRMLS_CC);
  MONGO_CHECK_INITIALIZED(cursor->link, MongoCursor);

  if (cursor->current && 
      Z_TYPE_P(cursor->current) == IS_ARRAY &&
      zend_hash_find(HASH_P(cursor->current), "_id", 4, (void**)&id) == SUCCESS) {

    if (Z_TYPE_PP(id) == IS_OBJECT) {
#if ZEND_MODULE_API_NO >= 20060613
      zend_std_cast_object_tostring(*id, return_value, IS_STRING TSRMLS_CC);
#else
      zend_std_cast_object_tostring(*id, return_value, IS_STRING, 0 TSRMLS_CC);
#endif /* ZEND_MODULE_API_NO >= 20060613 */
    }
    else {
      RETVAL_ZVAL(*id, 1, 0);
      convert_to_string(return_value);
    }
  }
  else {
    RETURN_STRING("", 1);
  }
}
コード例 #22
0
PHP_METHOD(Yaf_Request_Abstract, getQuery) {

	zval *name_param = NULL, *tmpDefault = NULL, *get = NULL, *_GET, *_0 = NULL;
	zval *name = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 0, 2, &name_param, &tmpDefault);

	if (!name_param) {
		ZEPHIR_INIT_VAR(name);
		ZVAL_EMPTY_STRING(name);
	} else {
		zephir_get_strval(name, name_param);
	}
	if (!tmpDefault) {
		tmpDefault = ZEPHIR_GLOBAL(global_null);
	}


	zephir_get_global(&_GET, SS("_GET") TSRMLS_CC);
	ZEPHIR_CPY_WRT(get, _GET);
	if (ZEPHIR_IS_STRING_IDENTICAL(name, "")) {
		RETVAL_ZVAL(_GET, 1, 0);
		RETURN_MM();
	}
	ZEPHIR_INIT_VAR(_0);
	if (zephir_array_isset(get, name)) {
		zephir_array_fetch(&_0, get, name, PH_NOISY, "yaf/request_abstract.zep", 115 TSRMLS_CC);
	} else {
		ZEPHIR_CPY_WRT(_0, tmpDefault);
	}
	RETURN_CCTOR(_0);

}
コード例 #23
0
ZEND_METHOD(Nc_Sql_MasterSlaveConnection, query)
{
    zval *sql, *flag;
    zval *connection, *r;

    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &sql, &flag) == FAILURE || Z_TYPE_P(flag) != IS_LONG)
        return;

    if (Z_LVAL_P(flag) & NC_SQL_CONNECTION_WRITE)
    {
        connection = nc_kernel_injection_property(getThis(), "masterConnection", Nc_Sql_Connection_ce);
    }
    else
    {
        connection = nc_kernel_injection_property(getThis(), "slaveConnection", Nc_Sql_Connection_ce);
    }

    if (!connection)
        return;

    r = zend_call_method_with_2_params(&connection, Z_OBJCE_P(connection), NULL, "query", &r, sql, flag);
    zval_ptr_dtor(&connection);

    if (!r)
    {
        zend_throw_exception(Nc_Sql_Exception_ce, "Cannot invoke query of injection property masterConnection/slaveConnection.", 0 TSRMLS_CC);
        return;
    }

    RETVAL_ZVAL(r, 0, 0);
    efree(r);
}
コード例 #24
0
ファイル: debug.zep.c プロジェクト: flaver12/cphalcon
/**
 * Produces an string representation of a variable
 */
PHP_METHOD(Phalcon_Debug, _getVarDump) {

	zephir_fcall_cache_entry *_3 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zephir_nts_static zephir_fcall_cache_entry *_1 = NULL;
	zval *variable, *className, *dumpedObject = NULL, *dump, *_0 = NULL, *_2 = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &variable);



	ZEPHIR_CALL_FUNCTION(&_0, "is_scalar", &_1, variable);
	zephir_check_call_status();
	if (zephir_is_true(_0)) {
		if (Z_TYPE_P(variable) == IS_BOOL) {
			if (zephir_is_true(variable)) {
				RETURN_MM_STRING("true", 1);
			} else {
				RETURN_MM_STRING("false", 1);
			}
		}
		if (Z_TYPE_P(variable) == IS_STRING) {
			ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_escapestring", NULL, variable);
			zephir_check_call_status();
			RETURN_MM();
		}
		RETVAL_ZVAL(variable, 1, 0);
		RETURN_MM();
	}
	if (Z_TYPE_P(variable) == IS_OBJECT) {
		ZEPHIR_INIT_VAR(className);
		zephir_get_class(className, variable, 0 TSRMLS_CC);
		ZEPHIR_INIT_VAR(dump);
		if ((zephir_method_exists_ex(variable, SS("dump") TSRMLS_CC) == SUCCESS)) {
			ZEPHIR_CALL_METHOD(&dumpedObject, variable, "dump", NULL);
			zephir_check_call_status();
			ZEPHIR_CALL_METHOD(&_2, this_ptr, "_getarraydump", &_3, dumpedObject);
			zephir_check_call_status();
			ZEPHIR_CONCAT_SVSVS(dump, "Object(", className, ": ", _2, ")");
		} else {
			ZEPHIR_CONCAT_SVS(dump, "Object(", className, ")</span>");
		}
		RETURN_CCTOR(dump);
	}
	if (Z_TYPE_P(variable) == IS_ARRAY) {
		ZEPHIR_CALL_METHOD(&_2, this_ptr, "_getarraydump", &_3, variable);
		zephir_check_call_status();
		ZEPHIR_CONCAT_SVS(return_value, "Array(", _2, ")");
		RETURN_MM();
	}
	if (Z_TYPE_P(variable) == IS_NULL) {
		RETURN_MM_STRING("null", 1);
	}
	zephir_gettype(return_value, variable TSRMLS_CC);
	RETURN_MM();

}
コード例 #25
0
ファイル: input.zep.c プロジェクト: leimengcheng/beeframework
PHP_METHOD(BeeFramework_Input, xss_clean) {

	zval *_3;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *value = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, _4;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &value);

	ZEPHIR_SEPARATE_PARAM(value);


	ZEPHIR_INIT_VAR(_0);
	ZVAL_STRING(_0, "/([\\x00-\\x08,\\x0b-\\x0c,\\x0e-\\x19])/", ZEPHIR_TEMP_PARAM_COPY);
	ZEPHIR_INIT_VAR(_1);
	ZVAL_STRING(_1, "", ZEPHIR_TEMP_PARAM_COPY);
	ZEPHIR_CALL_FUNCTION(&_2, "preg_replace", NULL, 6, _0, _1, value);
	zephir_check_temp_parameter(_0);
	zephir_check_temp_parameter(_1);
	zephir_check_call_status();
	ZEPHIR_CPY_WRT(value, _2);
	ZEPHIR_INIT_NVAR(_0);
	ZEPHIR_INIT_VAR(_3);
	zephir_create_array(_3, 8, 0 TSRMLS_CC);
	ZEPHIR_INIT_NVAR(_1);
	ZVAL_STRING(_1, "\"", 1);
	zephir_array_fast_append(_3, _1);
	ZEPHIR_INIT_NVAR(_1);
	ZVAL_STRING(_1, "\\", 1);
	zephir_array_fast_append(_3, _1);
	ZEPHIR_INIT_NVAR(_1);
	ZVAL_STRING(_1, "'", 1);
	zephir_array_fast_append(_3, _1);
	ZEPHIR_INIT_NVAR(_1);
	ZVAL_STRING(_1, "/", 1);
	zephir_array_fast_append(_3, _1);
	ZEPHIR_INIT_NVAR(_1);
	ZVAL_STRING(_1, "..", 1);
	zephir_array_fast_append(_3, _1);
	ZEPHIR_INIT_NVAR(_1);
	ZVAL_STRING(_1, "../", 1);
	zephir_array_fast_append(_3, _1);
	ZEPHIR_INIT_NVAR(_1);
	ZVAL_STRING(_1, "./", 1);
	zephir_array_fast_append(_3, _1);
	ZEPHIR_INIT_NVAR(_1);
	ZVAL_STRING(_1, "//", 1);
	zephir_array_fast_append(_3, _1);
	ZEPHIR_SINIT_VAR(_4);
	ZVAL_STRING(&_4, "", 0);
	zephir_fast_str_replace(&_0, _3, &_4, value TSRMLS_CC);
	ZEPHIR_CPY_WRT(value, _0);
	RETVAL_ZVAL(value, 1, 0);
	RETURN_MM();

}
コード例 #26
0
ファイル: transapi.zep.c プロジェクト: robertXin/trans_by_bd
PHP_METHOD(Transbybd_TransApi, __convert) {

	HashTable *_1$$3, *_4$$5;
	HashPosition _0$$3, _3$$5;
	zval *data;
	int ZEPHIR_LAST_CALL_STATUS;
	zephir_fcall_cache_entry *_7 = NULL;
	zval *args, *key = NULL, *val = NULL, *k = NULL, *v = NULL, **_2$$3, *_11$$3, _12$$3, **_5$$5, *_6$$6 = NULL, *_8$$6 = NULL, *_9$$7 = NULL, *_10$$7 = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &args);



	ZEPHIR_INIT_VAR(data);
	ZVAL_EMPTY_STRING(data);
	if (Z_TYPE_P(args) == IS_ARRAY) {
		zephir_is_iterable(args, &_1$$3, &_0$$3, 0, 0, "transbybd/transApi.zep", 106);
		for (
		  ; zephir_hash_get_current_data_ex(_1$$3, (void**) &_2$$3, &_0$$3) == SUCCESS
		  ; zephir_hash_move_forward_ex(_1$$3, &_0$$3)
		) {
			ZEPHIR_GET_HMKEY(key, _1$$3, _0$$3);
			ZEPHIR_GET_HVALUE(val, _2$$3);
			if (Z_TYPE_P(val) == IS_ARRAY) {
				zephir_is_iterable(val, &_4$$5, &_3$$5, 0, 0, "transbybd/transApi.zep", 102);
				for (
				  ; zephir_hash_get_current_data_ex(_4$$5, (void**) &_5$$5, &_3$$5) == SUCCESS
				  ; zephir_hash_move_forward_ex(_4$$5, &_3$$5)
				) {
					ZEPHIR_GET_HMKEY(k, _4$$5, _3$$5);
					ZEPHIR_GET_HVALUE(v, _5$$5);
					ZEPHIR_CALL_FUNCTION(&_6$$6, "rawurlencode", &_7, 11, v);
					zephir_check_call_status();
					ZEPHIR_INIT_LNVAR(_8$$6);
					ZEPHIR_CONCAT_VSVSVS(_8$$6, key, "[", k, "]=", _6$$6, "&");
					zephir_concat_self(&data, _8$$6 TSRMLS_CC);
				}
			} else {
				ZEPHIR_CALL_FUNCTION(&_9$$7, "rawurlencode", &_7, 11, val);
				zephir_check_call_status();
				ZEPHIR_INIT_LNVAR(_10$$7);
				ZEPHIR_CONCAT_VSVS(_10$$7, key, "=", _9$$7, "&");
				zephir_concat_self(&data, _10$$7 TSRMLS_CC);
			}
		}
		ZEPHIR_INIT_VAR(_11$$3);
		ZEPHIR_SINIT_VAR(_12$$3);
		ZVAL_STRING(&_12$$3, "&", 0);
		zephir_fast_trim(_11$$3, data, &_12$$3, ZEPHIR_TRIM_BOTH TSRMLS_CC);
		RETURN_CCTOR(_11$$3);
	}
	RETVAL_ZVAL(args, 1, 0);
	RETURN_MM();

}
コード例 #27
0
/* {{{ MongoCursor::batchSize
 */
PHP_METHOD(MongoCursor, batchSize) {
  long l;
  preiteration_setup;

  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &l) == FAILURE) {
    return;
  }

  cursor->batch_size = l;
  RETVAL_ZVAL(getThis(), 1, 0);
}
コード例 #28
0
/* {{{ MongoCursor::limit
 */
PHP_METHOD(MongoCursor, limit) {
  preiteration_setup;

  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &z) == FAILURE) {
    return;
  }
  convert_to_long(z);

  cursor->limit = Z_LVAL_P(z);
  RETVAL_ZVAL(getThis(), 1, 0);
}
コード例 #29
0
ファイル: connect_pool.c プロジェクト: reallovelei/php-cp
PHP_METHOD(pdo_connect_pool_PDOStatement, current)
{
    zval *pos, *rs, *row = NULL;
    zend_class_entry *ce;
    ce = Z_OBJCE_P(getThis());
    pos = cp_zend_read_property(ce, getThis(), "pos", sizeof ("pos") - 1, 0 TSRMLS_DC);
    rs = cp_zend_read_property(ce, getThis(), "rs", sizeof ("rs") - 1, 0 TSRMLS_DC);

    cp_zend_hash_index_find(Z_ARRVAL_P(rs), Z_LVAL_P(pos), (void**) &row);
    RETVAL_ZVAL(row, 1, 1);
}
コード例 #30
0
ファイル: output.zep.c プロジェクト: bschantz/cphalcon
/**
 * Unserializes data after retrieval
 */
PHP_METHOD(Phalcon_Cache_Frontend_Output, afterRetrieve) {

	zval *data;

	zephir_fetch_params(0, 1, 0, &data);



	RETVAL_ZVAL(data, 1, 0);
	return;

}