[function.sprintf]: Too few arguments - problem med æ og ø og å
Hej eksperter.Jeg er stødt ind i følgende fejl i mit galleri:
Warning: sprintf() [function.sprintf]: Too few arguments in /customers/lundthomsen.com/lundthomsen.com/httpd.www/billeder/.gallery/viewimage.php on line 334
·
Problemet opstår når mappen med billeder hedder noget med æ ø el. å f.eks. "dåb". Men hvis mappen hedder "daab" fungerer det fint.
Billederne i galleriet er delt op i mapper og jeg har derfor brug for at navngive mapper med æ ø og å.
Koden ser ud som følger (viewimage.php):
<?php
$_SERVER['DOCUMENT_ROOT'] .= "/billeder";
require($_SERVER['DOCUMENT_ROOT'] . "/config.php");
$uri = urldecode($_SERVER['REQUEST_URI']);
$imageFile = $_SERVER['DOCUMENT_ROOT'] . preg_replace("/\?(.*)$/", "", $uri);
$imageType = preg_replace("/\./", "", strtolower(strrchr($imageFile, ".")));
// Show the original image
if (isset($_GET['orig'])) {
if (!$GalleryAllowOriginal) {
exit("Downloading of the original image is disabled.");
}
if (!file_exists($imageFile)) {
exit("An error occurred while performing your request - file or directory does not exist.");
}
switch ($imageType) {
case 'jpg':
header('Content-Type: image/jpeg');
header("Content-Length: " . filesize($imageFile));
break;
case 'png':
header('Content-Type: image/png');
header("Content-Length: " . filesize($imageFile));
break;
case 'gif':
header('Content-Type: image/gif');
header("Content-Length: " . filesize($imageFile));
break;
default:
exit("An error occurred while performing your request - unsupported image type.");
break;
}
@readfile($imageFile);
exit;
// Show full EXIF information
} elseif (isset($_GET['exif'])) {
if (!$GalleryEXIFDumper) {
exit("This feature is disabled.");
}
if (!file_exists($imageFile)) {
exit("An error occurred while performing your request - file or directory does not exist.");
}
$exif_info = exif_read_data($imageFile, true, false);
$imageFile = preg_replace("/\//", "", strrchr($imageFile, "/"));
print("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n");
printf("<html>\n<head>\n<title>%s</title>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />\n</head>\n"
, "EXIF information in " . $imageFile);
print("<body><pre>\n");
if ($exif_info != false) {
print_r($exif_info);
} else {
print("No EXIF information within this image.");
}
print("</pre></body>\n</html>");
exit;
}
// Scale and show image
if (preg_match("/^\/\.cache\/(.*)$/", $uri)) {
require($_SERVER['DOCUMENT_ROOT'] . "/.gallery/functions.php");
if (!preg_match("/^\/\.cache([\/]*.*\/)([0-9]+)x([0-9]+)-(.*)$/", $uri)) {
exit("An error occurred while performing your request.");
}
$imageFile = $_SERVER['DOCUMENT_ROOT'] . preg_replace("/^\/\.cache([\/]*.*\/)([0-9]+)x([0-9]+)-(.*)$/", "$1$4", $uri);
$cacheFile = $_SERVER['DOCUMENT_ROOT'] . $uri;
if (!file_exists($imageFile)) {
exit("An error occurred while performing your request - file or directory does not exist.");
}
if (!file_exists($cacheFile)) {
$cacheSize = preg_replace("/^\/\.cache([\/]*.*\/)([0-9]+)x([0-9]+)-(.*)$/", "$2x$3", $uri);
list($cacheWidth, $cacheHeight) = explode("x", $cacheSize);
list($imageWidth, $imageHeight, $type, $attr) = getimagesize($imageFile);
if (!check_imagesize($cacheWidth, $cacheHeight, $imageWidth, $imageHeight, $thumb)) {
exit("An error occurred while performing your request - invalid image size.");
}
switch ($imageType) {
case 'jpg':
$image = imagecreatefromjpeg($imageFile);
break;
case 'png':
$image = imagecreatefrompng($imageFile);
break;
case 'gif':
$image = imagecreatefromgif($imageFile);
break;
default:
exit("An error occurred while performing your request - unsupported image type.");
break;
}
$cache = imagecreatetruecolor($cacheWidth, $cacheHeight);
imagecopyresampled($cache, $image, 0, 0, 0, 0, $cacheWidth, $cacheHeight, $imageWidth, $imageHeight);
// Copyright note
$tmp = strlen($GalleryCopyright);
if (!$thumb && ($tmp > 0)) {
$color = imagecolorallocate($cache, 255, 255, 255);
$x = $cacheWidth - (imagefontwidth(2) * $tmp) - 5;
$y = $cacheHeight - imagefontheight(2) - 1;
imagestring($cache, 2, $x, $y, $GalleryCopyright, $color);
}
switch ($imageType) {
case 'jpg':
imagejpeg($cache, $cacheFile, $GalleryImageQuality);
break;
case 'png':
imagepng($cache, $cacheFile);
break;
case 'gif':
imagegif($cache, $cacheFile);
break;
}
imagedestroy($image);
imagedestroy($cache);
}
switch ($imageType) {
case 'jpg':
header('Content-Type: image/jpeg');
header("Content-Length: " . filesize($cacheFile));
break;
case 'png':
header('Content-Type: image/png');
header("Content-Length: " . filesize($cacheFile));
break;
case 'gif':
header('Content-Type: image/gif');
header("Content-Length: " . filesize($cacheFile));
break;
default:
exit("An error occurred while performing your request - unsupported image type.");
break;
}
@readfile($cacheFile);
// View image
} else {
require($_SERVER['DOCUMENT_ROOT'] . "/.gallery/functions.php");
$directory = preg_replace("/\?(.*)$/", "", $uri);
$path = preg_replace("/[^\/]*\.(jpg|png|gif)$/i", "", $directory);
$dir = $_SERVER['DOCUMENT_ROOT'] . $path;
$cache = "/.cache" . $path;
if (empty($_GET['width'])) {
$width = preg_replace("/x([0-9]+)$/", "", $GalleryImageSize[0]);
} else {
$width = $_GET['width'];
if (!preg_match("/^([0-9]+)$/", $width)) {
exit("An error occurred while performing your request - integer value expected.");
}
}
if (!empty($_GET['slideshow']) && is_array($GallerySlideshowIntervals)) {
$slideshow = $_GET['slideshow'];
if (!preg_match("/^([0-9]+)$/", $slideshow)) {
exit("An error occurred while performing your request - integer value expected.");
}
}
if (!file_exists($imageFile)) {
exit("An error occurred while performing your request - file or directory does not exist.");
}
if (!check_width($width)) {
exit("An error occurred while performing your request - invalid width.");
}
$images = array();
$folderCount = 0;
$d = dir($dir);
while (false !== ($entry = $d->read())) {
if (preg_match("/^\.(.*)$/", $entry)) {
continue;
}
if (is_dir($dir . $entry)) {
$folderCount++;
} elseif (preg_match("/\.(jpg|png|gif)$/i", $entry)) {
$images[] = $entry;
}
}
$d->close();
sort($images);
$imageFile = preg_replace("/\//", "", strrchr($imageFile, "/"));
$imageCount = count($images);
$imageNumber = array_search($imageFile, $images) + 1;
$defaultWidth = preg_replace("/x([0-9]+)$/", "", $GalleryImageSize[0]);
require($_SERVER['DOCUMENT_ROOT'] . "/.gallery/header.php");
print("\n<table summary=\"image viewing\" width=\"100%\" cellspacing=\"0\">\n<tr>\n<td class=\"view\">\n");
// Show title
if ($GalleryImageDescription) {
$str = fetch_description($path);
if (strlen($str) > 0) {
list($title, $description) = explode("-|-", $str);
if (strlen($title) > 0) {
printf("<div class=\"album-title\">%s</div>\n\n", $title);
}
}
}
// Show description
if ($GalleryImageDescription) {
$description = fetch_description($path . $imageFile);
if (strlen($description) > 0) {
printf("\n<div class=\"description\">%s</div>", nl2br($description));
}
}
list($originalWidth, $originalHeight, $type, $attr) = getimagesize($dir . $imageFile);
list($imageWidth, $imageHeight) = get_imagesize($width, $originalWidth, $originalHeight);
$imageSize = $imageWidth . "x" . $imageHeight;
if ($GalleryAllowOriginal) {
printf("<a href=\"%s\">Original image</a><br />\n", ie_urlencode($path . $imageFile) . "?orig");
}
printf("<img src=\"%s\" alt=\"%s\" class=\"picture\" width=\"%d\" height=\"%d\" /><br />\n"
, ie_urlencode($cache . $imageSize . "-" . $imageFile), $imageFile, $imageWidth, $imageHeight);
$count = count($GalleryImageSize);
$str = "";
for ($i = 0; $i < $count; $i++) {
$tmp = preg_replace("/x([0-9]+)$/", "", $GalleryImageSize[$i]);
list($imageWidth, $imageHeight) = get_imagesize($tmp, $originalWidth, $originalHeight);
if ($tmp == $width) {
$str .= sprintf("%s%s", $imageWidth . "x" . $imageHeight, ($i != ($count - 1)) ? " " : "");
} else {
$str .= sprintf("<a href=\"%s%s\">%s</a>%s", ie_urlencode($path . $imageFile), ($tmp != $defaultWidth) ? "?width=" . $tmp : ""
, $imageWidth . "x" . $imageHeight, ($i != ($count - 1)) ? " " : "");
}
}
printf("Billede %d af %d i størrelsen %s pixels<br />\n", $imageNumber, $imageCount , $imageSize);
printf("[Ændre størrelse: %s%s]<br />\n", $str
, $GalleryImageComments ? " | <a href=\"java script:comments('" . $path . $imageFile . "');\">Comments</a>("
. fecth_comments_count($path, $imageFile) . ")" : "");
$total = $folderCount + $imageCount;
if (($GalleryMaxThumbnailsPerPage != 0) && ($total > $GalleryMaxThumbnailsPerPage)) {
$tmp = $folderCount + $imageNumber;
$page = intval($tmp / $GalleryMaxThumbnailsPerPage);
if ($tmp % $GalleryMaxThumbnailsPerPage) { $page++; }
} else {
$page = 1;
}
// Slideshow
if (is_array($GallerySlideshowIntervals)) {
$count = count($GallerySlideshowIntervals);
$str = "";
for ($i = 0; $i < $count; $i++) {
$tmp = $GallerySlideshowIntervals[$i];
if (isset($slideshow) && ($tmp == $slideshow)) {
$str .= sprintf("%s%s", $tmp, ($i != ($count - 1)) ? " " : "");
} else {
$str .= sprintf("<a href=\"%s%s%s\">%s</a>%s", ie_urlencode($path . $images[$imageNumber-1])
, ($width != $defaultWidth) ? "?width=" . $width . "&" : "?", "slideshow=$tmp"
, $tmp, ($i != ($count - 1)) ? " " : "");
}
}
$tmp = sprintf("%s", ($width != $defaultWidth) ? "?width=" . $width : "");
printf("[Slideshow: %s%s]<br />", $str
, isset($slideshow) ? " <a href=\"" . ie_urlencode($path . $images[$imageNumber-1]) . $tmp . "\">Fra</a>" : " Fra");
}
$up = sprintf("<a href=\"%s%s\">Tilbage til mappe</a>", ie_urlencode($path), ($page != 1) ? "?p=$page" : "");
$str = "· ";
if ($imageNumber == 1) {
if ($imageNumber == $imageCount) {
$str .= "Forrige · $up · Næste ·";
} else {
$str .= sprintf("Forrige · $up · <a href=\"%s%s\">Næste</a> ·", ie_urlencode($path . $images[$imageNumber])
, ($width != $defaultWidth) ? "?width=" . $width : "");
}
} elseif ($imageNumber < $imageCount) {
$str .= sprintf("<a href=\"%s%s\">Forrige</a> · $up · <a href=\"%s%s\">Næste</a> ·"
, ie_urlencode($path . $images[$imageNumber-2]), ($width != $defaultWidth) ? "?width=" . $width : ""
, ie_urlencode($path . $images[$imageNumber]), ($width != $defaultWidth) ? "?width=" . $width : "");
} else {
$str .= sprintf("<a href=\"%s%s\">Forrige</a> · $up · Næste ·", ie_urlencode($path . $images[$imageNumber-2])
, ($width != $defaultWidth) ? "?width=" . $width : "");
}
print("$str<br />\n");
require($_SERVER['DOCUMENT_ROOT'] . "/.gallery/footer.php");
}
?>