thanks for the help. Managed to make a half inelegant code here but it worked in all cases and had no problems.
$path = $_SERVER['SCRIPT_FILENAME'];
$pa = $path_parts = pathinfo($path);
$file = str_replace($path_parts['basename'],'',$_SERVER['SCRIPT_FILENAME']);
$file = str_replace($file,'',dirname(__FILE__));
$file = str_replace('library','conf1g.php',$file);
$file = str_replace($_SERVER['DOCUMENT_ROOT'],'',$file);
$subcasas = explode('/',str_replace($_SERVER['DOCUMENT_ROOT'],'',dirname(__FILE__)));
if(!is_file($file)){
$file = substr( $file, 1 );
for($x=0; $x<count($subcasas); $x++){
$file = str_replace($subcasas [$x],'..',$file);
if(is_file($file)){
break; //que deselegante
}
}
}
$this->file_config = $file;
require($this->file_config);
$this->user = $configuracoes_bd_mysql[USER];
$this->password = $configuracoes_bd_mysql[SENHA];
$this->host = $configuracoes_bd_mysql[HOST];
$this->db = $configuracoes_bd_mysql[DB];