Menu
I’m tryng to insert some PHP in the middle of a Html document, but it gets broken for some reason in a way that you can see the PHP in the middle of the html.
The “<?” seems to stop workin when “&&” come in the PHP code.
if($maxheight > 0 && $height2 > $maxheight) {
if(!isset($_FILES['image']) || $_FILES['image'] == "none" || $_FILES['image'] == "") {
$msg = "<font color='#0000FF' size='1' face='Arial, Helvetica, sans-serif'>Seleccione sus fotografías pulsando -Examinar-</font>";
break;
}
$tmp = getcwd()."/".$_FILES['image']['name'];
if(!@move_uploaded_file($_FILES['image']['tmp_name'], $tmp)) {
$msg = "<font color='#0000FF' size='1' face='Arial, Helvetica, sans-serif'>Ha ocurrido un error al subir la imagen</font>";
break;
}
$fp = fopen($tmp, "rb");
$str = fread($fp, filesize($tmp));
fclose($fp);
unlink($tmp);
$im1 = ImageCreateFromString($str);
$imgname = $Ref."thumb_1"; // Nombre imagen (se podría indicar desde el formulario)
$maxwidth = 300; // Ancho máximo
$maxheight = 150; // Alto máximo
$width1 = ImageSX($im1);
$height1 = ImageSY($im1);
$width2 = $maxwidth;
$height2 = floor(($width2 * $height1) / $width1);
if($maxheight > 0 && $height2 > $maxheight) {
$height2 = $maxheight;
$width2 = floor(($height2 * $width1) / $height1);
}
$im2 = ImageCreateTrueColor($width2, $height2);
ImageCopyResampled($im2, $im1, 0, 0, 0, 0, $width2, $height2, $width1, $height1);
ImageJpeg($im2, "thumb/".$imgname.".jpg"); // Se copia en temp/
$msg = "Ok";
$im3 = ImageCreateFromString($str);
$imgname2 = $Ref."_1"; // Nombre imagen (se podría indicar desde el formulario)
$maxwidth2 = 800; // Ancho máximo
$maxheight2 = 250; // Alto máximo
$width12 = ImageSX($im3);
$height12 = ImageSY($im3);
$width22 = $maxwidth2;
$height22 = floor(($width22 * $height12) / $width12);
if($maxheight2 > 0 && $height22 > $maxheight2) {
$height22 = $maxheight2;
$width22 = floor(($height22 * $width12) / $height12);
}
$im4 = ImageCreateTrueColor($width22, $height22);
ImageCopyResampled($im4, $im3, 0, 0, 0, 0, $width22, $height22, $width12, $height12);
ImageJpeg($im4, "full/".$imgname2.".jpg"); // Se copia en temp/
break;
if(!isset($_FILES['image']) || $_FILES['image'] == "none" || $_FILES['image'] == "") {
$msg = "<font color='#0000FF' size='1' face='Arial, Helvetica, sans-serif'>Seleccione sus fotografías pulsando -Examinar-</font>";break;
}
$tmp = getcwd()."/".$_FILES['image']['name'];
if(!@move_uploaded_file($_FILES['image']['tmp_name'], $tmp)) {
$msg = "<font color='#0000FF' size='1' face='Arial, Helvetica, sans-serif'>Ha ocurrido un error al subir la imagen</font>";break;
}
$fp = fopen($tmp, "rb");
$str = fread($fp, filesize($tmp));
fclose($fp);
unlink($tmp);
$im1 = ImageCreateFromString($str);
$imgname = $Ref."thumb_1"; // Nombre imagen (se podría indicar desde el formulario)
$maxwidth = 300; // Ancho máximo
$maxheight = 150; // Alto máximo
$width1 = ImageSX($im1);
$height1 = ImageSY($im1);
$width2 = $maxwidth;
$height2 = floor(($width2 * $height1) / $width1);
if($maxheight > 0 && $height2 > $maxheight) {
$height2 = $maxheight;
$width2 = floor(($height2 * $width1) / $height1);
}
$im2 = ImageCreateTrueColor($width2, $height2);
ImageCopyResampled($im2, $im1, 0, 0, 0, 0, $width2, $height2, $width1, $height1);
ImageJpeg($im2, "thumb/".$imgname.".jpg"); // Se copia en temp/
$msg = "Ok";
$im3 = ImageCreateFromString($str);
$imgname2 = $Ref."_1"; // Nombre imagen (se podría indicar desde el formulario)
$maxwidth2 = 800; // Ancho máximo
$maxheight2 = 250; // Alto máximo
$width12 = ImageSX($im3);
$height12 = ImageSY($im3);
$width22 = $maxwidth2;
$height22 = floor(($width22 * $height12) / $width12);
if($maxheight2 > 0 && $height22 > $maxheight2) {
$height22 = $maxheight2;
$width22 = floor(($height22 * $width12) / $height12);
}
$im4 = ImageCreateTrueColor($width22, $height22);
ImageCopyResampled($im4, $im3, 0, 0, 0, 0, $width22, $height22, $width12, $height12);
ImageJpeg($im4, "full/".$imgname2.".jpg"); // Se copia en temp/
break;
<i>
</i><?php
$link = mysql_connect('mm', 'mm', 'mm');
mysql_select_db("mm",$link2);
$result = mysql_query("SELECT * FROM fotos", $link);
$num_rows = mysql_num_rows($result);
$numref = ("$num_rows"+5000);
$iniciales = "rkf";
$Ref =$iniciales.$numref;
$sql = mysql_query("SELECT * FROM fotos WHERE ref= '$Ref'");
while(mysql_num_rows($sql) != 0){
$Ref =$iniciales.($numref++);
}
$msg = "";
if(!strcasecmp($_SERVER['REQUEST_METHOD'], "POST")) {
<i> </i>if(!isset($_FILES['image']) || $_FILES['image'] == "none" || $_FILES['image'] == "") {
<i> </i> $msg = "<font color='#0000FF' size='1' face='Arial, Helvetica, sans-serif'>Seleccione sus fotografías pulsando -Examinar-</font>";
<i> </i> exit;
<i> </i>}
<i> </i>$tmp = getcwd()."/".$_FILES['image']['name'];
<i> </i>if(!@move_uploaded_file($_FILES['image']['tmp_name'], $tmp)) {
<i> </i> $msg = "<font color='#0000FF' size='1' face='Arial, Helvetica, sans-serif'>Ha ocurrido un error al subir la imagen</font>";
<i> </i> exit;
<i> </i>}
<i> </i>$fp = fopen($tmp, "rb");
<i> </i>$str = fread($fp, filesize($tmp));
<i> </i>fclose($fp);
<i> </i>unlink($tmp);
<i> </i>$im1 = ImageCreateFromString($str);
<i> </i>$imgname = $Ref."thumb_1"; // Nombre imagen (se podría indicar desde el formulario)
<i> </i>$maxwidth = 300; // Ancho máximo
<i> </i>$maxheight = 150; // Alto máximo
<i> </i>$width1 = ImageSX($im1);
<i> </i>$height1 = ImageSY($im1);
<i> </i>$width2 = $maxwidth;
<i> </i>$height2 = floor(($width2 * $height1) / $width1);
<i> </i>if($maxheight > 0 && $height2 > $maxheight) {
<i> </i> $height2 = $maxheight;
<i> </i> $width2 = floor(($height2 * $width1) / $height1);
<i> </i>}
<i> </i>$im2 = ImageCreateTrueColor($width2, $height2);
<i> </i>ImageCopyResampled($im2, $im1, 0, 0, 0, 0, $width2, $height2, $width1, $height1);
<i> </i>ImageJpeg($im2, "thumb/".$imgname.".jpg"); // Se copia en temp/
<i> </i>$msg = "Ok";
<i> </i>$im3 = ImageCreateFromString($str);
<i> </i>$imgname2 = $Ref."_1"; // Nombre imagen (se podría indicar desde el formulario)
<i> </i>$maxwidth2 = 800; // Ancho máximo
<i> </i>$maxheight2 = 250; // Alto máximo
<i> </i>$width12 = ImageSX($im3);
<i> </i>$height12 = ImageSY($im3);
<i> </i>$width22 = $maxwidth2;
<i> </i>$height22 = floor(($width22 * $height12) / $width12);
<i> </i>if($maxheight2 > 0 && $height22 > $maxheight2) {
<i> </i> $height22 = $maxheight2;
<i> </i> $width22 = floor(($height22 * $width12) / $height12);
<i> </i>}
<i> </i>$im4 = ImageCreateTrueColor($width22, $height22);
<i> </i>ImageCopyResampled($im4, $im3, 0, 0, 0, 0, $width22, $height22, $width12, $height12);
<i> </i>ImageJpeg($im4, "full/".$imgname2.".jpg"); // Se copia en temp/
}
header("Location: newinsert.php?pos=".$pos."&color=".$color."&ref=".$Ref.");
?>
0.1.9 — BETA 4.28