Ver Mensaje Individual
  #17 (permalink)  
Antiguo 22/12/2007, 09:55
dfco
 
Fecha de Ingreso: octubre-2004
Mensajes: 2
Antigüedad: 19 años, 6 meses
Puntos: 0
generando Archivos RTF con PHP

TENGO TAMBIEN UN PROBLEMA CON ESTE PROGRAMA, EL MIO YA ME GENERA EL ARCHIVO PERO NO REALIZA CAMBIOS SOBRE ESTE. GENERA UNO IDENTICO QUE LA PLANTILLA.

AQUI LES DEJO TANTO LA PLANTILLA COMO EL CODIGO PHP A VER QUE PUEDE SER.

CODIGO PHP

<?
//Funcion que lee un archivo de texto y lo mete en una cadena
function leef ($fichero) {
$texto = file($fichero);
$tamleef = sizeof($texto);
for ($n=0;$n<$tamleef;$n++) {$todo= $todo.$texto[$n];}
return $todo;
}


//funcion que genera un rtf
function rtf($sql, $plantilla, $fsalida, $matequivalencias){
$pre=time();
$fsalida="C:/AppServ/www/helpsoporte/onsites/".$pre.$fsalida;
mysql_connect("localhost", "root", "admin");
//Paso no 1.-Leo una plantilla rtf
$txtplantilla = leef($plantilla);
//Paso no.2 Saca cabecera, el cuerpo y el final
$matriz=explode("sectd", $txtplantilla);
$cabecera=$matriz[0]."sectd";
$inicio=strlen($cabecera);
$final=strrpos($txtplantilla,"}");
$largo=$final-$inicio;
$cuerpo=substr($txtplantilla, $inicio, $largo);
//Paso no.3 Escribo el fichero
$punt = fopen($fsalida, "w");
fputs($punt, $cabecera);
mysql_select_db("helpdesk");
$result =mysql_query($sql);
While($row=mysql_fetch_object($result)){
$despues=$cuerpo;
foreach ($matequivalencias as $dato) {
$datosql=$row->$dato[1];

$datosql= stripslashes ($datosql);

$datortf=$dato[0];
echo"DATO DE LA BD".$datosql;
echo"DATO A REEMPLAZAR".$datortf;
$despues=str_replace($datortf,$datosql,$despues);
}
fputs($punt,$despues);
$saltopag="\par \page \par";
fputs($punt,$saltopag);
}
fputs($punt,"}");
fclose ($punt);
return $fsalida;
}

$plantilla="C:/AppServ/www/helpsoporte/plantilla.rtf";
$sql="select cedula from usercaso where nocaso='3'";

$equivalencias[0][0]="#*cedula*#";
$equivalencias[0][1]="cedula";
$salida = rtf($sql, $plantilla, "certificado.rtf", $equivalencias);
$salida ="<A href='$salida'>Obtener RTF</a>";
echo "<p>$salida</p>";
?>

PLANTILLA RTF

PRUEBA DE ARCHIVO #*cedula*#


Y NO ME FUNCIONA LOS DATOS LLEGAN BIEN HASTA EL MOMENTO DE REALIZAR EL CAMBIO PERO NO LOS REALIZA.

DE ANTEMANO MUCHAS GRACIAS.