[eluser]J. Manuel[/eluser]
the link that start the process i need to fix is:
INFO - 2011-03-11 14:15:26 --> <a location='/es/downloads/genera_mobile/6773'><img src="http://portal.localhost/images/kmlmobile.png" alt="Descargar Archivo KML(Google Earth)" title="Descargar Archivo KML(Google Earth)" border="0" style="float:left;" /></a>
So, genera_mobile method is called.
This method is like that:
function genera_mobile($id_terminal)
{
return $this->gkml->genera_mobile($id_terminal);
}
genera_mobile method at gkml library is:
function genera_mobile($idterminal)
{
$CI =& get_instance();
$CI->load->model('modelo_kml');
$CI->load->language('downloads');
$CI->load->library('Session');
$session_id = $CI->session->userdata('session_id');
$retornado = $CI->modelo_kml->_terminal($idterminal)->result_array();
$this->file = $this->xml_start."\r\n";
$this->file .= $this->cab_movil."\r\n";
$this->file .= '<Document>'."\r\n";
$this->file .= $this->terminal_movil($idterminal,$retornado[0]['name'],$session_id);
$this->file .= '</Document>'."\r\n";
$this->file .= '</kml>'."\r\n";
print $this->download_kml($this->file,'mobile_terminal_'.$retornado[0]['name']);
}
print $this->download_kml($this->file,'mobile_terminal_'.$retornado[0]['name']); line is where the error is.
The script might download the generated file ($this->file)
The file downloaded is:
<?xml version="1.0" encoding="UTF-8"?>
<kml >
<Document>
<NetworkLink id="6773">
<name>META</name>
<flyToView>1</flyToView>
<Link>
<href>http://portal.localhost/downloads/kml_mobile/6773/2949cda11484a8c93c16f41d8f3810ea</href>
<refreshMode>onInterval</refreshMode>
<refreshInterval>60</refreshInterval>
</Link>
</NetworkLink>
</Document>
</kml>
<br />
<b>Fatal error</b>: ob_start() [<a href='ref.outcontrol'>ref.outcontrol</a>]: Cannot use output buffering in output buffering display handlers in <b>/var/www/trunk/system/libraries/Exceptions.php</b> on line <b>161</b><br />
All is right, instead the last error line attached at the end of the downloaded file. I can't figure out the reason and solve this error.
that line is created by an internal codeigniter error handler, I examined the error description deeper and I got the error is:
INFO - 2011-03-11 13:19:40 --> Cannot modify header information - headers already sent by (output started at /var/www/trunk/system/application/libraries/Gkml.php:305)
This line 305 is the one I mentioned before:
function genera_mobile($idterminal)
{
...
print $this->download_kml($this->file,'mobile_terminal_'.$retornado[0]['name']);
}
And this is the download_kml funcion.
function download_kml($file,$name = 'googleearth')
{
$fsize = mb_strlen($file);
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type: application/vnd.google-earth.kml+xml");
header("Content-Disposition: attachment; filename=$name.kml");
header("Content-Transfer-Encoding: quoted-printable");
header("Content-Length: " . $fsize);
return $this->file;
}
I can't figure out why ...
Thank you very much for your time !