include("connessione.php");
if ($userlog<>"OK"){
session_start();
session_destroy();
session_start();
header("Location:login.php");
exit();
}
if($passa=="5"){
unlink("/web/htdocs/www.encocrema.com/home/img_cantieri/$nome");
unlink("/web/htdocs/www.encocrema.com/home/img_cantieri/t_$nome");
$sql_up = "UPDATE cantiere SET ";
$sql = "SELECT * FROM cantiere where id='$id'";
$result=mysql_db_query($database,$sql,$db);
$row=mysql_fetch_assoc($result);
$nome=$nome."|";
$foto_dettaglio = str_replace($nome,"",$row["fotografie"]);
$sql_up.= "fotografie = '$foto_dettaglio' ";
$sql_up.= "where id='$id' ";
$result=mysql_db_query($database,$sql_up,$db);
$passa=1;
}
if($passa=="99"){
unlink("/web/htdocs/www.encocrema.com/home/img_cantieri/$nome");
unlink("/web/htdocs/www.encocrema.com/home/img_cantieri/t_$nome");
$sql_up = "UPDATE cantiere SET ";
$sql_up.= "foto = '' ";
$sql_up.= "where id='$id' ";
$result=mysql_db_query($database,$sql_up,$db);
$passa=1;
}
if($passa=="3"){
$sql_delete = "DELETE FROM cantiere WHERE ID='$id'";
$result_delete = mysql_db_query($database, $sql_delete, $db);
}
if($passa=="2"){
ini_set("memory_limit", "128M");
if(copy( $fprincipale , "/web/htdocs/www.encocrema.com/home/img_cantieri/$fprincipale_name" )){
$new_file_d="cantiere_".mktime().".jpg";
$image = "/web/htdocs/www.encocrema.com/home/img_cantieri/$fprincipale_name";
$newimage = "/web/htdocs/www.encocrema.com/home/img_cantieri/t_$new_file_d";
$image_quality = 80;
$addborder = 1;
$max_height = 60;
$max_width = 60;
$src_img = ImageCreateFromJpeg($image);
$orig_x = ImageSX($src_img);
$orig_y = ImageSY($src_img);
$new_y = $max_height;
$new_x = $orig_x/($orig_y/$max_height);
if ($new_x > $max_width) {
$new_x = $max_width;
$new_y = $orig_y/($orig_x/$max_width);
}
$dst_img = ImageCreateTrueColor($new_x,$new_y);
ImageCopyResampled($dst_img, $src_img, 0, 0, 0, 0, $new_x, $new_y, $orig_x, $orig_y);
if ($addborder == 1) {
// Add border
$black = ImageColorAllocate($dst_img, 0, 0, 0);
ImageSetThickness($dst_img, 1);
ImageLine($dst_img, 0, 0, $new_x, 0, $black);
ImageLine($dst_img, 0, 0, 0, $new_y, $black);
ImageLine($dst_img, $new_x-1, 0, $new_x-1, $new_y, $black);
ImageLine($dst_img, 0, $new_y-1, $new_x, $new_y-1, $black);
}
ImageJpeg($dst_img, $newimage, $image_quality);
ImageDestroy($src_img);
ImageDestroy($dst_img);
$newimage = "/web/htdocs/www.encocrema.com/home/img_cantieri/$new_file_d";
$image_quality = 80;
$addborder = 1;
$max_height = 400;
$max_width = 400;
// Main code
$src_img = ImageCreateFromJpeg($image);
$orig_x = ImageSX($src_img);
$orig_y = ImageSY($src_img);
$new_y = $max_height;
$new_x = $orig_x/($orig_y/$max_height);
if ($new_x > $max_width) {
$new_x = $max_width;
$new_y = $orig_y/($orig_x/$max_width);
}
$dst_img = ImageCreateTrueColor($new_x,$new_y);
ImageCopyResampled($dst_img, $src_img, 0, 0, 0, 0, $new_x, $new_y, $orig_x, $orig_y);
if ($addborder == 1) {
// Add border
$black = ImageColorAllocate($dst_img, 0, 0, 0);
ImageSetThickness($dst_img, 1);
ImageLine($dst_img, 0, 0, $new_x, 0, $black);
ImageLine($dst_img, 0, 0, 0, $new_y, $black);
ImageLine($dst_img, $new_x-1, 0, $new_x-1, $new_y, $black);
ImageLine($dst_img, 0, $new_y-1, $new_x, $new_y-1, $black);
}
ImageJpeg($dst_img, $newimage, $image_quality);
ImageDestroy($src_img);
ImageDestroy($dst_img);
unlink("/web/htdocs/www.encocrema.com/home/img_cantieri/$fprincipale_name");
$foto_principale=$new_file_d;
}
if(copy( $dettagli , "/web/htdocs/www.encocrema.com/home/img_cantieri/$dettagli_name" )){
$new_file_d="cantiere_".mktime().".jpg";
$image = "/web/htdocs/www.encocrema.com/home/img_cantieri/$dettagli_name";
$newimage = "/web/htdocs/www.encocrema.com/home/img_cantieri/t_$new_file_d";
$image_quality = 80;
$addborder = 1;
$max_height = 60;
$max_width = 60;
$src_img = ImageCreateFromJpeg($image);
$orig_x = ImageSX($src_img);
$orig_y = ImageSY($src_img);
$new_y = $max_height;
$new_x = $orig_x/($orig_y/$max_height);
if ($new_x > $max_width) {
$new_x = $max_width;
$new_y = $orig_y/($orig_x/$max_width);
}
$dst_img = ImageCreateTrueColor($new_x,$new_y);
ImageCopyResampled($dst_img, $src_img, 0, 0, 0, 0, $new_x, $new_y, $orig_x, $orig_y);
if ($addborder == 1) {
// Add border
$black = ImageColorAllocate($dst_img, 0, 0, 0);
ImageSetThickness($dst_img, 1);
ImageLine($dst_img, 0, 0, $new_x, 0, $black);
ImageLine($dst_img, 0, 0, 0, $new_y, $black);
ImageLine($dst_img, $new_x-1, 0, $new_x-1, $new_y, $black);
ImageLine($dst_img, 0, $new_y-1, $new_x, $new_y-1, $black);
}
ImageJpeg($dst_img, $newimage, $image_quality);
ImageDestroy($src_img);
ImageDestroy($dst_img);
$newimage = "/web/htdocs/www.encocrema.com/home/img_cantieri/$new_file_d";
$image_quality = 80;
$addborder = 1;
$max_height = 400;
$max_width = 400;
// Main code
$src_img = ImageCreateFromJpeg($image);
$orig_x = ImageSX($src_img);
$orig_y = ImageSY($src_img);
$new_y = $max_height;
$new_x = $orig_x/($orig_y/$max_height);
if ($new_x > $max_width) {
$new_x = $max_width;
$new_y = $orig_y/($orig_x/$max_width);
}
$dst_img = ImageCreateTrueColor($new_x,$new_y);
ImageCopyResampled($dst_img, $src_img, 0, 0, 0, 0, $new_x, $new_y, $orig_x, $orig_y);
if ($addborder == 1) {
// Add border
$black = ImageColorAllocate($dst_img, 0, 0, 0);
ImageSetThickness($dst_img, 1);
ImageLine($dst_img, 0, 0, $new_x, 0, $black);
ImageLine($dst_img, 0, 0, 0, $new_y, $black);
ImageLine($dst_img, $new_x-1, 0, $new_x-1, $new_y, $black);
ImageLine($dst_img, 0, $new_y-1, $new_x, $new_y-1, $black);
}
ImageJpeg($dst_img, $newimage, $image_quality);
ImageDestroy($src_img);
ImageDestroy($dst_img);
unlink("/web/htdocs/www.encocrema.com/home/img_cantieri/$dettagli_name");
ini_set("memory_limit", "32M");
$foto_dettaglio=$foto_dettaglio.$new_file_d."|";
}
if($id==""){
$sql_in = "INSERT INTO cantiere (data) VALUES ('".mktime()."')";
$result_in = mysql_db_query($database, $sql_in, $db);
$id=mysql_insert_id($db);
}
$sql_up = "UPDATE cantiere SET ";
$sql_up.= "nome = '$nome', ";
$sql_up.= "gd = '$gd', ";
$sql_up.= "descrizione1 = '$descrizione1', ";
$sql_up.= "scheda = '$scheda', ";
$sql_up.= "scheda2 = '$scheda2', ";
$sql_up.= "descrizione1_eng = '$descrizione1_eng', ";
$sql_up.= "scheda_eng = '$scheda_eng', ";
$sql_up.= "scheda2_eng = '$scheda2_eng', ";
$sql_up.= "categoria = '$categoria', ";
$sql_up.= "pubblica = '$pubblica', ";
$sql_up.= "datainizio = '$datainizio', ";
$sql_up.= "datafine = '$datafine', ";
$sql_up.= "citta = '$citta', ";
$sql_up.= "collaboratori = '$collaboratori', ";
$sql_up.= "elenco = '$elenco', ";
$sql_up.= "tipo = '$tipo', ";
if($new_file_d<>""){
$sql_up.= "fotografie = '$foto_dettaglio', ";
}
if($foto_principale<>""){
$sql_up.= "foto = '$foto_principale', ";
}
$sql_up.= "copertina = '$copertina' ";
$sql_up.= "WHERE id = '$id'";
$result = mysql_db_query($database,$sql_up,$db);
header("location:cantieri.php?passa=1&id=$id");
}
if($passa=="1"){
$query = "SELECT * FROM cantiere where id='$id'";
$result = mysql_db_query($database, $query, $db);
$row=mysql_fetch_assoc($result);
?>
..::: Enco engineering consulting s.r.l. :::..
exit();
}
$count = mysql_query("SELECT COUNT(id) FROM cantiere");
$res_count = mysql_fetch_row($count);
$tot_records = $res_count[0];
$per_page = 24;
$tot_pages = ceil($tot_records / $per_page);
$current_page = (!$_GET['page']) ? 1 : (int)$_GET['page'];
$primo = ($current_page - 1) * $per_page;
$query = "SELECT * FROM cantiere ";
$query.= "order by id DESC LIMIT $primo, $per_page";
$result = mysql_db_query($database, $query, $db);
?>
..::: Enco engineering consulting s.r.l. :::..
mysql_close(); ?>