thoughton:digitallife banner
about downloads imagery work
-- How To... --

FolderBlog on IIS


I've been using the great little image CMS known as FolderBlog for the last few months and have been thoroughly enjoying it. The program is easily adapted to any design and is incredibly simple to use, allowing even the most computer-illiterate client to easily upload images and edit captions. The official program doesn't have an easy non-FTP way to delete images, but that is taken care of by a nifty little modification by Björn-Frederic Limmer known as FolderBlog Ikue Reloaded (FIR). FIR also adds other features - including adding .gif compatibility and sorting by EXIF data - but it is the delete function that tops my list.


However, my entire experience of using FolderBlog and FIR has been on Apache servers. Today I tried to use it on an IIS server and ran into many problems. Searching for information to solve this problem was difficult, largely due to the lack of a search function at the official FolderBlog forums. The incomplete documentation for the current version 3 of the program also doesn't help! As a result I've decided to post my solution here:

Step 1
Edit fb_settings.php and replace:

$use_alt_url = 0;

With:
$use_alt_url = 1;

Note: To post new images and captions after changing this setting you need to browse to fb.php?p=post instead of fb.php/post/

Step 2
IIS does not have the REQUEST_URI function. We need to use PHP_SELF instead. Open up fb.php and replace all instances (there should be 5) of:

$_SERVER["REQUEST_URI"]

With:
$_SERVER['PHP_SELF']

Step 3
Some IIS servers which are running PHP as CGI may not have EXIF enabled. This was the case with my IIS server. In order to fix the exif_imagedata errors that result from this I had to find this section in the FIR version of fb.php:

function createThumb($filename,$altname="") {
global $photo_directory, $thumb_directory, $thumb_maxsize, $square_thumbs, $file_extension;


// MODIFIED BY IKUE
// check if it is a supported filetype, better error handling included

$original = @imagecreatefromjpeg($filename);
// could it be loaded? if not, try another
if (!$original) { $original = @imagecreatefrompng($filename); }
// could it be loaded? if not, try another
if (!$original) { $original = @imagecreatefromgif($filename); }
// still not loaded? dear... give an error message
if (!$original) { showerror("You attempted to load an unsupported filetype. Check your file extensions in the settings.<br>File: $filename"); }


$x = imagesx($original);
$y = imagesy($original);
if ($square_thumbs==0) {
$scale = $thumb_maxsize/max($x, $y);
$newx = $x*$scale;
$newy = $y*$scale;
$thumb = imagecreatetruecolor($newx, $newy);
imagecopyresampled($thumb, $original, 0, 0, 0, 0, $newx, $newy, $x, $y);
} elseif ($square_thumbs==1) {
$scale = $thumb_maxsize/min($x, $y);
$newx = $x*$scale;
$newy = $y*$scale;
$thumb = imagecreatetruecolor($thumb_maxsize, $thumb_maxsize);
imagecopyresampled($thumb, $original, ($newx-$thumb_maxsize)/-2, ($newy-$thumb_maxsize)/-2, 0, 0, $newx, $newy, $x, $y);
}
if (exif_imagetype($filename)==IMAGETYPE_JPEG) {
imagejpeg($thumb, $thumb_directory . basename($filename), 95);
if ($altname) {
imagejpeg($thumb, $thumb_directory . $altname, 95);
}
} else
if (exif_imagetype($filename)==IMAGETYPE_GIF) {
imagegif($thumb, $thumb_directory . basename($filename));
if ($altname) {
imagegif($thumb, $thumb_directory . $altname);
}
} else
if (exif_imagetype($filename)==IMAGETYPE_PNG) {
imagepng($thumb, $thumb_directory . basename($filename));
if ($altname) {
imagepng($thumb, $thumb_directory . $altname);
}
} else { showerror("You attempted to load an unsupported filetype. Check your file extensions in the settings.<br>File: $filename"); }

return array($newx, $newy);
}

And replace it with the same function from the original unmodified (not FIR) version of fb.php (this will remove EXIF functionality from FIR, but I don't need it anyway):

function createThumb($filename,$altname="") {
global $photo_directory, $thumb_directory, $thumb_maxsize, $square_thumbs, $file_extension;
$original = imagecreatefromjpeg($filename);
$x = imagesx($original);
$y = imagesy($original);
if ($square_thumbs==0) {
$scale = $thumb_maxsize/max($x, $y);
$newx = $x*$scale;
$newy = $y*$scale;
$thumb = imagecreatetruecolor($newx, $newy);
imagecopyresampled($thumb, $original, 0, 0, 0, 0, $newx, $newy, $x, $y);
} elseif ($square_thumbs==1) {
$scale = $thumb_maxsize/min($x, $y);
$newx = $x*$scale;
$newy = $y*$scale;
$thumb = imagecreatetruecolor($thumb_maxsize, $thumb_maxsize);
imagecopyresampled($thumb, $original, ($newx-$thumb_maxsize)/-2, ($newy-$thumb_maxsize)/-2, 0, 0, $newx, $newy, $x, $y);
}
imagejpeg($thumb, $thumb_directory . basename($filename), 95);
if ($altname) {
imagejpeg($thumb, $thumb_directory . $altname, 95);
}
return array($newx, $newy);
}

Step 4
Almost there! The FIR gallery now displays in my web browser, but although the thumbnails are visible none of links work. It turns out that all of the links were missing the ?q= characters. Thanks to this thread all you need to do to fix this is edit fb.php and replace this line:

$path[0] = $fbfile = str_replace($path[1], "", $_SERVER['PHP_SELF']) . (isset($_GET["p"]) ? "" : "?p=");

With this line:
$path[0] = $fbfile = str_replace($path[1], "", $_SERVER['PHP_SELF']) . (isset($_GET["p"]) ? "?p=" : "?p=");

Step 5
There is no step 5. You should now have a working FolderBlog installation on a Windows IIS server.


Posted on 30 December 2005, to How To... | Internet

Related entries

Site update - 4 February 2004

Trackback Pings

TrackBack URL for this entry:
http://thoughton.co.uk/cgi-bin/mt-tb-dlosx.cgi/178

Listed below are links to weblogs that reference FolderBlog on IIS:

» FolderBlog on IIS from
How to get FolderBlog running on a Windows IIS server. [Read More]

Tracked on July 21, 2006 11:49 PM

Comments

i am on a similar boat - but the problem i am experiencing now is in fb_settings : $photo_directory = is requiring my absolute path - but it will not show images, where all the other options are not requiing absolute paths just "thumbs/" and so forth - do you have any idea as to how i could change that requirement - i read all 21 pages of the forums with no answer.

by: lgarion at January 26, 2006 6:08 AM

Hmm, are you gettting any error messages? Can you post them exactly as they appear?

My $photo_directory variable just uses the 'photos/' path.

Do any of your photos appear at all?

Can you provide a link to the folderblog installation?

Good luck!

by: Tim Houghton at January 26, 2006 1:40 PM

Awesome tutorial, thanks a lot for this.

by: Fred at February 10, 2006 3:55 AM

Subscribe to comments

Enter your email address in the box below to receive an email notification whenever a new comment is posted to this entry.

Email address:

Post a comment










Remember personal info?


Click a smiley!
:) ;) 8) :| :(
:P :X :? :mad: :D
:o :cry: :shock: :blush: :roll:



Security code
Please enter this security number in the space below (this prevents automated responses).



Category icon Sponsors