Project

General

Profile

Bug #46020 » imagesize_6_2.php

Marc Reiter, 2014-03-26 13:07

 
<?php

$conf = include 'LocalConfiguration.php';

$c = mysql_connect(
$conf['DB']['host'],
$conf['DB']['username'],
$conf['DB']['password']
);

if(!$c) {
die('Could not connect: ' . mysql_error());
}

mysql_select_db($conf['DB']['database']);

$sql = 'SELECT sf.identifier, sf.storage, sfm.file FROM sys_file as sf, sys_file_metadata as sfm WHERE sfm.width=0 AND sfm.height=0 AND sf.uid = sfm.file';
$result = mysql_query($sql);

if (!$result) {
echo "Could not successfully run query ($sql) from DB: " . mysql_error();
exit;
}


while ($row = mysql_fetch_assoc($result)) {
$filename = $row['identifier'];
if($row['storage'] == 1) {
$filename = '/fileadmin' . $filename;
}
$filename = '..' . $filename;

$mime = mime_content_type($filename);
list($width, $height) = getimagesize($filename);

$sql = 'UPDATE sys_file_metadata SET width = \'' . $width . '\', height = \'' . $height . '\' WHERE file = ' . $row['file'];

$r = mysql_query($sql);
if (!$r) {
echo "Could not successfully run query ($sql) from DB: " . mysql_error();
}

echo $sql . "\n\n";

}
?>
(6-6/8)