ecco il codice completo:
codice:
<?php
session_start();
ini_set('memory_limit', '2048M');
include("inc.php");
include("admin.php");
include("layout/header.php");
$dir = (isset($_GET["dir"])) ? trim ((string)$_GET["dir"]): '';
if(empty($dir))
{
echo "<p>L'url e vuoto</p>";
}else
{
$query = "SELECT * FROM photo_categories WHERE dir=:dir";
$stmt = $db->prepare( $query );
$stmt->bindParam(':dir', $dir , PDO::PARAM_STR);
$stmt->execute();
$row = $stmt->fetch();
$num = $stmt->rowCount();
if($num > 0)
{
$row_dir = $row["dir"];
$id_categories = $row["id"];
}else
{
$msg = "<p>Nessun dato</p>";
}
?><p class="info_title">Foto</p>
<table class="control">
<tr>
<td>
<a href="album_view.php?id=<?php echo $id_categories; ?>">Home</a>
</td>
</tr>
</table>
<?php
if(isset($error)){ echo $error;}
if(isset($msg)){ echo $msg;} else {
$cartella = opendir("".$dir_admin_photo."".$row_dir.'/auto/');
while ($file = readdir($cartella)) {
$file_array[] = $file;
}
foreach ($file_array as $file) {
if ( $file == ".." || $file == ".") {
continue;
}
$file_name = "".sha1($file).".jpg";
$resize = new ResizeImage("".$dir_admin_photo."".$row_dir."/auto/".$file."");
$resize->resizeTo(800, 600, 'maxWidth');
$resize->saveImage("".$dir_admin_photo."".$row_dir."/big/".strtolower($file_name)."");
$resize->resizeTo(150, 150, 'maxWidth');
$resize->saveImage("".$dir_admin_photo."".$row_dir."/thumb/".strtolower($file_name)."");
$content = "";
$active =1;
$data_reg = date("Y-m-d H:i:s");
$id_users = $_SESSION["id_users"];
$query = "INSERT INTO photo (id_categories,url,content,active,data_reg)VALUES(:id_categories,:url,:content,:active,:data_reg)";
$stmt = $db->prepare($query);
$stmt->bindParam(':id_categories', $id_categories, PDO::PARAM_INT);
$stmt->bindParam(':url', $file_name, PDO::PARAM_STR);
$stmt->bindParam(':content',$content, PDO::PARAM_STR);
$stmt->bindParam(':active', $active, PDO::PARAM_INT);
$stmt->bindParam(':data_reg', $data_reg, PDO::PARAM_STR);
$stmt->execute();
unlink("".$dir_admin_photo."".$row_dir."/auto/".$file."");
}
echo "Fatto";
sleep(30);
}
}
include("layout/footer.php");
?>
grazie mille e spero che si risolva il problema.