static void accel_file_in_cache(int type, INTERNAL_FUNCTION_PARAMETERS)
{
	char *filename;
	int filename_len;
#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO
	zval **zfilename;

	if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zfilename) == FAILURE) {
		WRONG_PARAM_COUNT;
	}
	convert_to_string_ex(zfilename);
	filename = Z_STRVAL_PP(zfilename);
	filename_len = Z_STRLEN_PP(zfilename);
#elif ZEND_EXTENSION_API_NO == PHP_5_3_X_API_NO
	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) {
		return;
	}
#else
	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &filename, &filename_len) == FAILURE) {
		return;
	}
#endif
	if(filename_len > 0) {
		if(filename_is_in_cache(filename, filename_len TSRMLS_CC)) {
			RETURN_TRUE;
		}
	}

	php_stat(filename, filename_len, type, return_value TSRMLS_CC);
}
Ejemplo n.º 2
0
/** {{{ yaf_config_ini_modified
*/
static int yaf_config_ini_modified(zval * file, long ctime TSRMLS_DC) {
	zval  n_ctime;
	php_stat(Z_STRVAL_P(file), Z_STRLEN_P(file), 7 /* FS_CTIME */ , &n_ctime TSRMLS_CC);
	if (Z_TYPE(n_ctime) != IS_BOOL && ctime != Z_LVAL(n_ctime)) {
		return Z_LVAL(n_ctime);
	}
	return 0;
}
Ejemplo n.º 3
0
void zephir_filemtime(zval *return_value, zval *path)
{
	if (EXPECTED(Z_TYPE_P(path) == IS_STRING)) {
		php_stat(Z_STRVAL_P(path), (php_stat_len)(Z_STRLEN_P(path)), FS_MTIME, return_value);
	} else {
		ZVAL_FALSE(return_value);
	}
}
Ejemplo n.º 4
0
zend_bool futil_file_exists(char * filename, int filename_len TSRMLS_DC)
{
    zval tmp;
    php_stat(filename, filename_len, FS_EXISTS, &tmp TSRMLS_CC);
    zend_bool ret = Z_LVAL(tmp) ? true : false;
    zval_dtor( &tmp );
    return ret;
}
Ejemplo n.º 5
0
/** {{{ gene_file_modified
*/
int gene_file_modified(char *file, long ctime TSRMLS_DC)
{
	zval  n_ctime;
	php_stat(file, strlen(file), 6 /* FS_MTIME */ , &n_ctime TSRMLS_CC);
	if (Z_TYPE(n_ctime) != IS_BOOL && ctime != Z_LVAL(n_ctime)) {
		return Z_LVAL(n_ctime);
	}
	return 0;
}
Ejemplo n.º 6
0
/* {{{ yaf_config_ini_modified
 *  检查配置文件是否修改,修改的话返回最近修改时间,否则返回0	
 */
static int yaf_config_ini_modified(zval * file, long ctime TSRMLS_DC) {
	zval  n_ctime;
	/* 获取文件上一次状态改变的时间 */
	php_stat(Z_STRVAL_P(file), Z_STRLEN_P(file), 7 /* FS_CTIME */ , &n_ctime TSRMLS_CC);
	if (Z_TYPE(n_ctime) != IS_BOOL && ctime != Z_LVAL(n_ctime)) {
		/* 如果文件有改动则返回最近一次状态改变的时间 */
		return Z_LVAL(n_ctime);
	}
	return 0;
}
Ejemplo n.º 7
0
/* {{{ Mosquitto\Client::setTlsCertificates() */
PHP_METHOD(Mosquitto_Client, setTlsCertificates)
{
	mosquitto_client_object *object;
	char *ca_path = NULL, *cert_path = NULL, *key_path = NULL, *key_pw = NULL;
	int ca_path_len = 0, cert_path_len = 0, key_path_len = 0, key_pw_len, retval = 0;
	zval stat;
	zend_bool is_dir = 0;
	int (*pw_callback)(char *, int, int, void *) = NULL;

	PHP_MOSQUITTO_ERROR_HANDLING();
	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!|s!s!s!",
				&ca_path, &ca_path_len,
				&cert_path, &cert_path_len,
				&key_path, &key_path_len,
				&key_pw, &key_pw_len) == FAILURE) {
		PHP_MOSQUITTO_RESTORE_ERRORS();
		return;
	}

	if ((php_check_open_basedir(ca_path TSRMLS_CC) < 0) ||
		(php_check_open_basedir(cert_path TSRMLS_CC) < 0) ||
		(php_check_open_basedir(key_path TSRMLS_CC) < 0))
	{
		PHP_MOSQUITTO_RESTORE_ERRORS();
		return;
	}

	PHP_MOSQUITTO_RESTORE_ERRORS();

	object = (mosquitto_client_object *) zend_object_store_get_object(getThis() TSRMLS_CC);

	php_stat(ca_path, ca_path_len, FS_IS_DIR, &stat TSRMLS_CC);
	is_dir = Z_BVAL(stat);

	if (key_pw != NULL) {
		pw_callback = php_mosquitto_pw_callback;
		MQTTG(client_key) = estrdup(key_pw);
		MQTTG(client_key_len) = key_pw_len;
	}

	if (is_dir) {
		retval = mosquitto_tls_set(object->client, NULL, ca_path, cert_path, key_path, pw_callback);
	} else {
		retval = mosquitto_tls_set(object->client, ca_path, NULL, cert_path, key_path, pw_callback);
	}

	php_mosquitto_handle_errno(retval, errno TSRMLS_CC);
	RETURN_LONG(retval);
}
Ejemplo n.º 8
0
/**
 * Checks if a file exist
 *
 */
int zephir_file_exists(zval *filename)
{
	zval return_value;

	if (Z_TYPE_P(filename) != IS_STRING) {
		return FAILURE;
	}

	php_stat(Z_STRVAL_P(filename), (php_stat_len) Z_STRLEN_P(filename), FS_EXISTS, &return_value);

	if (Z_TYPE(return_value) != IS_TRUE) {
		return FAILURE;
	}

	return SUCCESS;
}