Foros del Web » Programando para Internet » PHP »

Problema con una clase

Estas en el tema de Problema con una clase en el foro de PHP en Foros del Web. Hola a todos, espero puedan ayudarme, les cuento, utilizado una aplicación pre fabricada en php, es un sistema de afiliados, en mi panel de control ...
  #1 (permalink)  
Antiguo 28/05/2010, 17:04
Avatar de oscarenzo  
Fecha de Ingreso: julio-2007
Ubicación: Barcelona
Mensajes: 167
Antigüedad: 16 años, 9 meses
Puntos: 2
Problema con una clase

Hola a todos, espero puedan ayudarme, les cuento, utilizado una aplicación pre fabricada en php, es un sistema de afiliados, en mi panel de control tengo una opción para hacer backups de mi base de datos a través de la aplicación, pero es aquí cuando tengo el problema, cuando hago click en el boton de hacer backup, recibo el siguiente mensaje:

Código:
Warning: Cannot modify header information - headers already sent by (output started at /home/usuario/public_html/langs/spanish.php:1) in /home/usuario/public_html/merchants/Maintenance.class.php on line 229

Warning: Cannot modify header information - headers already sent by (output started at /home/usuario/public_html/langs/spanish.php:1) in /home/usuario/public_html/merchants/Maintenance.class.php on line 230

Warning: Cannot modify header information - headers already sent by (output started at /home/ganandod/public_html/langs/spanish.php:1) in /home/ganandod/public_html/merchants/Maintenance.class.php on line 231
DROP TABLE IF EXISTS pa_accounting; CREATE TABLE pa_accounting( accountingid int(10) unsigned NOT NULL, dateinserted datetime NOT NULL, datefrom datetime NOT NULL, dateto datetime NOT NULL, note text, paypalfile varchar(100), mbfile varchar(100), wirefile varchar(100), PRIMARY KEY (accountingid), UNIQUE KEY UC_accountingid (accountingid) ); ....( más resultados de sql)
Espero puedan ayudarme, les adjunto el código del archivo que aparece ahí en el error a ver si alguien me podría ayudar.

Código del archivo:
Código:
<?
class Maintenance
{
    var $settingsTable = 'pa_settings';
    
    function process()
    {
        if(!empty($_POST['commited']))
        {
            switch($_POST['action'])
            {
                case 'edit':
                if($this->saveSettings())
                    return;
                break;
                
                case 'backup':
                if($this->showBackupForm())
                    return;
                break;
                
                case 'restore':
                if($this->showRestoreForm())
                    return;
                break;
            }
        }
        
        switch($_REQUEST['action'])
        {
                case 'startbackup':
                if($this->processBackup())
                    return;
                break;       
        }
        
        $this->show();    
    }  
    
    //------------------------------------------------------------------------

    function showBackupForm()
    {
        echo '<meta http-equiv="refresh" content="2;url=index_exp.php?md=Maintenance&action=startbackup&gzipcompress='.$_REQUEST['gzipcompress'].'">';
        
?>
<table width="450" class=tableresult border=0 cellspacing=0 cellpadding=2>
<tr>
  <td class=header align=center><?=AFF_G_DBBACKUP?></td>
</tr>
<tr>
  <td class=dir_form valign=top align="center" nowrap><?=AFF_G_BACKUPINPROCESS?></td>
</tr>
</table>
<?
        
        return true;
    }   
     
    //------------------------------------------------------------------------

    function showRestoreForm()
    {
        $errorMsg = '';
        
        @set_time_limit(1200);
        
        // check file upload
        if($_FILES['sqlfile']['name'] == '')
            $errorMsg .= AFF_G_YOUHAVETOSELECTFILE.'<br>';
        else
        {
            if(!is_uploaded_file($_FILES['sqlfile']['tmp_name'])) 
                $errorMsg .= AFF_G_FILEUPLOADATTACK.'<br>';
        }
        
        if(preg_match("/\.gz$/is", $_FILES['sqlfile']['name']))
        {
            // check if zip extension is installed
            $gzipCompress = false;
            $phpver = phpversion();
            
            if($phpver >= "4.0")
            {
                if(extension_loaded("zlib"))
                    $gzipCompress = true;
            }
            
            if(!$gzipCompress)
                $errorMsg .= AFF_G_GZIPNOTINSTALLED.'<br>';
        }
        
        if($errorMsg != '')
        {
            showMsg($errorMsg);
            $this->show();
        }
        else
        {
            if($gzipCompress)
            {
                $file = gzopen($_FILES['sqlfile']['tmp_name'], 'rb');
                $sqlQuery = "";
                while( !gzeof($file) )
                {
                    $sqlQuery .= gzgets($file, 100000);
                }
            }
            else
            {
                $sqlQuery = file_get_contents($_FILES['sqlfile']['tmp_name']);
            }
            
            if($sqlQuery != "")
            {
?>
<table width="450" class=tableresult border=0 cellspacing=0 cellpadding=2>
<tr>
  <td class=header align=center><?=AFF_G_DBBACKUP?></td>
</tr>
<tr>
  <td class=dir_form valign=top align="center" nowrap><?=AFF_G_RESTOREINPROCESS?></td>
</tr>
<tr>
  <td class=dir_form valign=top align="center" nowrap>
<?                
                // Strip out sql comments...
                $sqlQuery = removeMysqlComments($sqlQuery);
                $pieces = splitSqlFile($sqlQuery, ";");
                
                $sqlCount = count($pieces);
                $executedCount = 0;
                for($i = 0; $i < $sqlCount; $i++)
                {
                    $sql = trim($pieces[$i]);
                    
                    if(!empty($sql) and $sql[0] != "#")
                    {
                        $executedCount++;
                        
                        if($executedCount % 10 == 0)
                        {
                            echo '.';
                            flush();
                        }
                        
                        $ret = DBUnit::execute($sql, __FILE__, __LINE__);
                        if (!$ret)
                        {
                            showMsg(AFF_G_DBERROR);
                            return true;
                        }   
                    }
                }
            }
        }
?>
  </td>
</tr>
<tr>
  <td class=dir_form valign=top align="center" nowrap><?=AFF_G_RESTOREFINISHEDOK?></td>
</tr>
</table>
<?                
        
        return true;
    }   

    //------------------------------------------------------------------------

    function processBackup()
    {
        @set_time_limit(1200);

        $tables = array
                  (
                  pa_accounting,
                  pa_affiliates,
                  pa_affiliatescampaigns,
                  pa_banners,
                  pa_campaigncategories,
                  pa_campaigns,
                  pa_emailtemplates,
                  pa_history,
                  pa_impressions,
                  pa_merchants,
                  pa_recurringcommissions,
                  pa_settings,
                  pa_transactions,
                  seq_pa_affiliates,
                  seq_pa_affiliatescampaigns,
                  seq_pa_banners,
                  seq_pa_campaigncategories,
                  seq_pa_campaigns,
                  seq_pa_emailtemps
                  );
        
        $gzipCompress = false;
        if($_REQUEST['gzipcompress'] == 1)
        {
            $phpver = phpversion();

            if($phpver >= "4.0")
			{
			    if(extension_loaded("zlib"))
				{
					$gzipCompress = true;
				}
			}
		}

        if($gzipCompress)
        {
            @ob_start();
            @ob_implicit_flush(0);
            header("Pragma: no-cache");    
            header("Content-Type: application/x-gzip; name=\"db_backup.sql.gz\"");
            header("Content-disposition: attachment; filename=\"db_backup.sql.gz\"");
        }
        else
        {
            header("Pragma: no-cache");     
            header("Content-Type: Binary; name=\"db_backup.sql\"");
            header("Content-disposition: attachment; filename=db_backup.sql");
        }

        // create statements
        foreach($tables as $table)
        {
            DBUnit::getTableCreateStatement($table);
        }
        
        // insert statements
        foreach($tables as $table)
        {
            DBUnit::getTableInsertStatement($table);
        }
        
        if($gzipCompress)
        {
            $size = ob_get_length();
            $crc = crc32(ob_get_contents());
            $contents = gzencode(ob_get_contents());
            ob_end_clean();
            echo $contents;
            //"\x1f\x8b\x08\x00\x00\x00\x00\x00".substr($contents, 0, strlen($contents) - 4).gzip_PrintFourChars($crc).gzip_PrintFourChars($size);
		}
        exit;
        
        return true;
    }
    
    //------------------------------------------------------------------------
    
    function show()
    {
        Templates::includeTemplate('maintenance.php');
    }
    
    //------------------------------------------------------------------------
}
?>
Agradezco de antemano.

Un saludo.
  #2 (permalink)  
Antiguo 28/05/2010, 17:36
Avatar de abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 15 años
Puntos: 1517
Respuesta: Problema con una clase

Lee esto http://www.forosdelweb.com/wiki/PHP:...lready_sent%3F
y esto http://www.forosdelweb.com/wiki/PHP:...n_line_4%22%3F
__________________
Verifica antes de preguntar.
Los verdaderos amigos se hieren con la verdad, para no perderlos con la mentira. - Eugenio Maria de Hostos
  #3 (permalink)  
Antiguo 29/05/2010, 07:21
Avatar de oscarenzo  
Fecha de Ingreso: julio-2007
Ubicación: Barcelona
Mensajes: 167
Antigüedad: 16 años, 9 meses
Puntos: 2
Respuesta: Problema con una clase

Hola abimaelrc, gracias por tu ayuda, al final me sirvió bastante el segundo enlace.

Con respecto a tu sugerencia, la próxima vez la pondré en practica si no que con ese error me sentía un poco desorientado.

Gracias nuevamente, saludos.

Etiquetas: clase
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 01:49.