Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1496
Modified Files:
serendipity_admin_installer.inc.php
serendipity_functions_images.inc.php
serendipity_functions_installer.inc.php
Log Message:
* Fixed bug with quicktime movies in PHP < 4 3.9, use a wrapping serendipity_getimagesize() call for special places.
* Fixed bug to correctly autodetect serendipity core directory when document-root is not the real document-root, as found on some hosting setups. Tested working on shared setups.
Index: serendipity_admin_installer.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin_installer.inc.php,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -d -r1.74 -r1.75
--- serendipity_admin_installer.inc.php 9 Aug 2004 09:49:54 -0000 1.74
+++ serendipity_admin_installer.inc.php 18 Aug 2004 10:15:45 -0000 1.75
@@ -17,7 +17,7 @@
if (!empty($_POST['serendipityPath'])) {
$serendipity_core = $_POST['serendipityPath'];
} else {
- $serendipity_core = $_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['PHP_SELF']) . '/';
+ $serendipity_core = serendipity_httpCoreDir();
}
} else {
$serendipity_core = $serendipity['serendipityPath'];
Index: serendipity_functions_installer.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions_installer.inc.php,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- serendipity_functions_installer.inc.php 9 Aug 2004 09:49:54 -0000 1.30
+++ serendipity_functions_installer.inc.php 18 Aug 2004 10:15:45 -0000 1.31
@@ -267,7 +267,7 @@
$abort = false;
if (IS_installed !== true && $_abort !== true) {
$serendipity_root = dirname($_SERVER['PHP_SELF']) . '/';
- $serendipity_core = $_SERVER['DOCUMENT_ROOT'] . $serendipity_root;
+ $serendipity_core = serendipity_httpCoreDir();
$old_htaccess = @file_get_contents($serendipity_core . '.htaccess');
$fp = @fopen($serendipity_core . '.htaccess', 'w');
$serendipity_host = preg_replace('@^([^:]+):?.*$@', '\1', $_SERVER['HTTP_HOST']);
@@ -758,4 +758,12 @@
return true;
}
}
+
+function serendipity_httpCoreDir() {
+ if (!empty($_SERVER['SCRIPT_FILENAME'])) {
+ return dirname($_SERVER['SCRIPT_FILENAME']) . '/';
+ }
+
+ return $_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['PHP_SELF']) . '/';
+}
?>
\ No newline at end of file
Index: serendipity_functions_images.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions_images.inc.php,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- serendipity_functions_images.inc.php 14 Aug 2004 23:33:15 -0000 1.32
+++ serendipity_functions_images.inc.php 18 Aug 2004 10:15:45 -0000 1.33
@@ -188,27 +188,18 @@
}
// Calculate name of thumbnail
- $t = serendipity_parseFileName($file);
- $f = $t[0];
- $suf = $t[1];
+ $t = serendipity_parseFileName($file);
+ $f = $t[0];
+ $suf = $t[1];
+ $ft_mime = serendipity_guessMime($suf);
$infile = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $directory . $file;
$outfile = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $directory . $f . '.' . $serendipity['thumbSuffix'] . '.' . $suf;
- $fdim = @getimagesize($infile);
+ $fdim = @serendipity_getimagesize($infile, $ft_mime);
- if (!is_array($fdim)) {
- // The file is no image.
- $fdim = array(
- 0 => 0,
- 1 => 0,
- 'mime' => serendipity_guessMime($suf)
- );
+ if (isset($fdim['noimage'])) {
$r = array(0, 0);
} else {
- if (empty($fdim['mime'])) {
- $fdim['mime'] = serendipity_guessMime($suf);
- }
-
if ($serendipity['magick'] !== true) {
$r = serendipity_resize_image_gd($infile, $outfile, $size);
} else {
@@ -266,7 +257,7 @@
$serendipity['imageList'] = serendipity_fetchImagesFromDatabase(0, 0, $total);
foreach ($serendipity['imageList'] as $k => $file) {
- $is_image = ( 0 === strpos(strtolower($file['mime']), "image/") );
+ $is_image = (0 === strpos(strtolower($file['mime']), "image/"));
if ($is_image) {
$update = false;
@@ -533,10 +524,10 @@
continue;
}
- $ffull = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $files[$x];
- $fthumb = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $f[0] . '.' . $serendipity['thumbSuffix'] . '.' . $f[1];
- $fbase = basename($f[0]);
- $fdir = dirname($f[0]) . DIRECTORY_SEPARATOR;
+ $ffull = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $files[$x];
+ $fthumb = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $f[0] . '.' . $serendipity['thumbSuffix'] . '.' . $f[1];
+ $fbase = basename($f[0]);
+ $fdir = dirname($f[0]) . DIRECTORY_SEPARATOR;
if ($fdir == '.' . DIRECTORY_SEPARATOR) {
$fdir = '';
}
@@ -546,11 +537,8 @@
continue;
}
- $fdim = getimagesize($ffull);
-
- if (empty($fdim['mime'])) {
- $fdim['mime'] = serendipity_guessMime($f[1]);
- }
+ $ft_mime = serendipity_guessMime($f[1]);
+ $fdim = serendipity_getimagesize($ffull, $ft_mime);
$rs = serendipity_db_query("SELECT * FROM {$serendipity['dbPrefix']}images
WHERE name = '" . serendipity_db_escape_string($fbase) . "'
@@ -1014,4 +1002,33 @@
return true;
}
-?>
+
+function serendipity_getimagesize($file, $ft_mime = '', $suf = '') {
+ if (empty($ft_mime) && !empty($suf)) {
+ $ft_mime = serendipity_guessMime($suf);
+ }
+
+ $fdim = @getimagesize($file);
+
+ if (is_array($fdim)) {
+ if (empty($fdim['mime'])) {
+ $fdim['mime'] = $ft_mime;
+ }
+
+ if ($fdim['mime'] == 'image/vnd.wap.wbmp' && $ft_mime == 'video/x-quicktime') {
+ // PHP Versions prior to 4.3.9 reported .mov files wrongly as WAP. Fix this and mark the file as 'non-image' with 0x0 dimensions
+ $fdim['mime'] = $ft_mime;
+ }
+ } else {
+ // The file is no image. Return a fake array so that files are inserted (but without a thumb)
+ $fdim = array(
+ 0 => 0,
+ 1 => 0,
+ 'mime' => $ft_mime,
+ 'noimage' => true
+ );
+ }
+
+ return $fdim;
+}
+?>
\ No newline at end of file
|