query($query); if (!$result) return false; } return true; } function getInfo($filename) { global $database; $url = '../uploads/big/' . $filename; $iptcArray = array(); $info = getimagesize($url, $iptcArray); // General information $return['type'] = $info['mime']; $return['width'] = $info[0]; $return['height'] = $info[1]; $return['date'] = date('d.m.Y', filectime($url)); $return['time'] = date('H:i:s', filectime($url)); // Size $size = filesize($url)/1024; if ($size>=1024) $return['size'] = round($size/1024, 1) . ' MB'; else $return['size'] = round($size, 1) . ' KB'; // IPTC Metadata Fallback $return['title'] = ''; $return['description'] = ''; // IPTC Metadata $iptcInfo = iptcparse($iptcArray['APP13']); if (is_array($iptcInfo)) { $temp = $iptcInfo['2#105'][0]; if (isset($temp)&&strlen($temp)>0) $return['title'] = $temp; $temp = $iptcInfo['2#120'][0]; if (isset($temp)&&strlen($temp)>0) $return['description'] = $temp; } // EXIF Metadata Fallback $return['orientation'] = ''; $return['iso'] = ''; $return['aperture'] = ''; $return['make'] = ''; $return['model'] = ''; $return['shutter'] = ''; $return['focal'] = ''; $return['takeDate'] = ''; $return['takeTime'] = ''; // EXIF Metadata if ($info['mime']=='image/jpeg'&&function_exists('exif_read_data')&&@exif_read_data($url, 'EXIF', 0)) { $exif = exif_read_data($url, 'EXIF', 0); $temp = $exif['Orientation']; if (isset($temp)) $return['orientation'] = $temp; $temp = $exif['ISOSpeedRatings']; if (isset($temp)) $return['iso'] = $temp; $temp = $exif['COMPUTED']['ApertureFNumber']; if (isset($temp)) $return['aperture'] = $temp; $temp = $exif['Make']; if (isset($temp)) $return['make'] = $exif['Make']; $temp = $exif['Model']; if (isset($temp)) $return['model'] = $temp; $temp = $exif['ExposureTime']; if (isset($temp)) $return['shutter'] = $exif['ExposureTime'] . ' Sec.'; $temp = $exif['FocalLength']; if (isset($temp)) $return['focal'] = ($temp/1) . ' mm'; $temp = $exif['DateTimeOriginal']; if (isset($temp)) { $exifDate = explode(' ', $temp); $date = explode(':', $exifDate[0]); $return['takeDate'] = $date[2].'.'.$date[1].'.'.$date[0]; $return['takeTime'] = $exifDate[1]; } } // Security foreach(array_keys($return) as $key) $return[$key] = mysqli_real_escape_string($database, $return[$key]); return $return; } function createThumb($filename, $width = 200, $height = 200) { global $settings; $url = "../uploads/big/$filename"; $info = getimagesize($url); $photoName = explode(".", $filename); $newUrl = "../uploads/thumb/".$photoName[0].".jpeg"; $newUrl2x = "../uploads/thumb/".$photoName[0]."@2x.jpeg"; // Set position and size $thumb = imagecreatetruecolor($width, $height); $thumb2x = imagecreatetruecolor($width*2, $height*2); if ($info[0]<$info[1]) { $newSize = $info[0]; $startWidth = 0; $startHeight = $info[1]/2 - $info[0]/2; } else { $newSize = $info[1]; $startWidth = $info[0]/2 - $info[1]/2; $startHeight = 0; } // Create new image switch($info['mime']) { case 'image/jpeg': $sourceImg = imagecreatefromjpeg($url); break; case 'image/png': $sourceImg = imagecreatefrompng($url); break; case 'image/gif': $sourceImg = imagecreatefromgif($url); break; default: return false; } imagecopyresampled($thumb,$sourceImg,0,0,$startWidth,$startHeight,$width,$height,$newSize,$newSize); imagecopyresampled($thumb2x,$sourceImg,0,0,$startWidth,$startHeight,$width*2,$height*2,$newSize,$newSize); imagejpeg($thumb,$newUrl,$settings['thumbQuality']); imagejpeg($thumb2x,$newUrl2x,$settings['thumbQuality']); return true; } function importPhoto($name, $albumID = 0) { $tmp_name = "../uploads/import/$name"; $info = getimagesize($tmp_name); $size = filesize($tmp_name); $nameFile = array(array()); $nameFile[0]['name'] = $name; $nameFile[0]['type'] = $info['mime']; $nameFile[0]['tmp_name'] = $tmp_name; $nameFile[0]['error'] = 0; $nameFile[0]['size'] = $size; if (upload($nameFile, $albumID)) return true; return false; } function importUrl($url, $albumID = 0) { if (strpos($url, ',')!==false) { // Multiple photos $url = explode(',', $url); foreach ($url as &$key) { $key = str_replace(' ', '%20', $key); if (@getimagesize($key)) { $pathinfo = pathinfo($key); $filename = $pathinfo['filename'].".".$pathinfo['extension']; $tmp_name = "../uploads/import/$filename"; copy($key, $tmp_name); } } return importServer($albumID); } else { // One photo $url = str_replace(' ', '%20', $url); if (@getimagesize($url)) { $pathinfo = pathinfo($url); $filename = $pathinfo['filename'].".".$pathinfo['extension']; $tmp_name = "../uploads/import/$filename"; copy($url, $tmp_name); return importPhoto($filename, $albumID); } } return false; } function importServer($albumID = 0) { global $database; $i = 0; $files = glob('../uploads/import/*'); foreach ($files as $file) { if (@getimagesize($file)) { if (!importPhoto(basename($file), $albumID)) return false; $i++; } } if ($i===0) return "Warning: Folder empty!"; return true; } ?>