DM Albums™ and WAMP Fatal Error November 10th, 2009

It has been brought to the Development team’s attention that DM Albums™ does not activate when installing on a WAMP (Apache, MySQL, PHP on Windows) installation.  The plugin will download and install without problem, but when activating, you will get the following error:

Plugin could not be activated because it triggered a fatal error.

= 0) { $contents[$i] = $file; $i++; } } closedir($dir); natcasesort($contents); $contents = array_values($contents); return $contents; } function dm_get_caption($photo) { $caption = “”; if(file_exists(dirname($photo) . “/browse.cap”)) { $lines = file(dirname($photo) . “/browse.cap”); foreach($lines as $line) { //line starts with the image name, remove image name and leading whitespace, display caption $matches = array(); $matchcount = 0; $matchcount = preg_match_all(“/(^” . basename($photo) . “:\s)(.*)/i”, $line, $matches); if($matchcount > 0) { $filename = $matches[0][1]; $caption = trim($matches[2][0]); if(strlen($caption) > 0) return trim(“$caption”); else return trim($caption); } } } return $caption; } function dm_put_caption($photo, $displaycaption) { $directory = dirname($photo); $picturename = basename($photo); $captionfilename = $directory . “/browse.cap”; if(!file_exists($captionfilename)) { fopen($captionfilename, “x+”); } $lines = file($captionfilename); if(count($lines) == 0) $lines = array(); $foundcaption = 0; $linecount = 0; while($linecount < count($lines)) { $line = $lines[$linecount]; //line starts with the image name, remove image name and leading whitespace, display caption $matches = array(); $matchcount = 0; $matchcount = preg_match_all("/(^$picturename:\s)(.*)/i", $line, $matches); if($matchcount > 0) { $foundcaption = 1; $filename = $matches[0][1]; $caption = $displaycaption; $lines[$linecount] = “$picturename:\t$caption\n”; } $linecount++; } if($foundcaption === 0) { $lines[$linecount] = $picturename . “:\t$displaycaption\n”; } $linecount = 0; $captionfilecontents = “”; while($linecount < count($lines)) { if(preg_match("/^\s$/", $lines[$linecount]) != 1) $captionfilecontents = $captionfilecontents . $lines[$linecount]; $linecount++; } $fh = fopen($captionfilename, "w+"); $captionfilecontents = html_entity_decode($captionfilecontents); $captionfilecontents = stripslashes($captionfilecontents); fwrite($fh, $captionfilecontents); } function dm_get_title($photoalbum) { $ablum_title = ""; if(file_exists($photoalbum . "/browse.cap")) { $lines = file($photoalbum . "/browse.cap"); foreach($lines as $line) { //line starts with the image name, remove image name and leading whitespace, display caption $matches = array(); $matchcount = 0; $matchcount = preg_match_all("/(^DM_ALBUM_TITLE:\s)(.*)/i", $line, $matches); if($matchcount > 0) { $filename = $matches[0][1]; $ablum_title = trim($matches[2][0]); if(strlen($ablum_title) > 0) return trim(“$ablum_title”); else return trim($ablum_title); } } } return $ablum_title; } function dm_put_title($album, $displaycaption) { $directory = $album; $captionfilename = $directory . “/browse.cap”; if(!file_exists($captionfilename)) { fopen($captionfilename, “x+”); } $lines = file($captionfilename); if(count($lines) == 0) $lines = array(); $foundcaption = 0; $linecount = 0; while($linecount < count($lines)) { $line = $lines[$linecount]; //line starts with the image name, remove image name and leading whitespace, display caption $matches = array(); $matchcount = 0; $matchcount = preg_match_all("/(^DM_ALBUM_TITLE:\s)(.*)/i", $line, $matches); if($matchcount > 0) { $foundcaption = 1; $filename = $matches[0][1]; $caption = $displaycaption; $lines[$linecount] = “DM_ALBUM_TITLE:\t$caption\n”; } $linecount++; } if($foundcaption === 0) { $lines[$linecount] = “DM_ALBUM_TITLE:\t$displaycaption\n”; } $linecount = 0; $captionfilecontents = “”; while($linecount < count($lines)) { if(preg_match("/^\s$/", $lines[$linecount]) != 1) $captionfilecontents = $captionfilecontents . $lines[$linecount]; $linecount++; } $fh = fopen($captionfilename, "w+"); $captionfilecontents = html_entity_decode($captionfilecontents); $captionfilecontents = stripslashes($captionfilecontents); fwrite($fh, $captionfilecontents); } function dm_get_album_datecmp($a, $b) { return ($a[1] > $b[1]) ? -1 : 1; } function dm_get_album_alphacmp($a, $b) { return (strtolower(basename($a[0])) < strtolower(basename($b[0]))) ? -1 : 1; } function dm_get_album_delete($album) { $handle = opendir($album); while (false!==($item = readdir($handle))) { $type = filetype($item); if($item != '.' && $item != '..') { if($type != "link" && is_dir($album.'/'.$item)) { dm_get_album_delete($album.'/'.$item); } else { unlink($album.'/'.$item); } } } closedir($handle); rmdir($album); } function dm_sanitize($folder) { $bad_chars = "/[^\w\s\(\)\:\.-]+/"; $replacement_chars = ""; $folder = trim(preg_replace($bad_chars, $replacement_chars, $folder), '/\\'); $folder = str_replace("..", "", $folder); $folder = str_replace("/", "", $folder); $folder = str_replace("\\", "", $folder); return $folder; } function dm_getuploaddirectory() { global $blog_id; if(get_option('DM_ALBUMS_UPLOADDIR') == "" || get_option('DM_ALBUMS_UPLOADDIR') == "/") { update_option('DM_ALBUMS_UPLOADDIR', get_option('DM_ALBUMS_CORE_DEFAULT_UPLOADDIR')); } return str_replace("{BLOG_ID}", $blog_id, get_option('DM_ALBUMS_UPLOADDIR')); } function dm_user_uploaddirectory() { $DM_UUP = get_option('DM_ALBUMS_UUP'); if($DM_UUP == 1) { global $current_user, $_POST, $_GET; get_currentuserinfo(); $user_upload_directory = $current_user->user_email; if(!isset($user_upload_directory) || empty($user_upload_directory)) { $user_upload_directory = isset($_POST["dm_uud"]) ? $_POST["dm_uud"] : $_GET["dm_uud"]; $user_upload_directory = str_replace(“../”, “”, $user_upload_directory); $user_upload_directory = str_replace(“/”, “”, $user_upload_directory); $user_upload_directory = str_replace(“\\”, “”, $user_upload_directory); $user_upload_directory = str_replace(“‘”, “”, $user_upload_directory); $user_upload_directory = str_replace(“\”", “”, $user_upload_directory); $user_upload_directory = trim($user_upload_directory, ‘/\\’); } //$user_upload_directory = str_replace(“@”, “_at_”, $user_upload_directory); return $user_upload_directory . “/”; } } function dm_is_wpmu() { if(is_dir($_SERVER['DOCUMENT_ROOT'] . ‘/wp-content/mu-plugins’)) return true; else return false; } function dm_isUserAdmin() { global $blog_id; // NON WPMU AND ADMINS if(!dm_is_wpmu() && current_user_can(‘level_10′)) return true; // WPMU AND BASE BLOG if(dm_is_wpmu() && $blog_id == 1) return true; return false; } ?>

We have been able to reproduce the error and are working on a resolution. Check back for further updates.

UPDATE @ 11/10/2009 2:30 Pacific
The cause of this error has been identified as being the opening shorthand PHP tag in /wp-content/plugins/dm-albums/php/includes.php. To resolve the issue, change the first line of this file from <? to <?php.

Productions is correcting all shorthand PHP tags and will be issuing a service release after testing is complete. As always, thank you for your support and feedback.

UPDATE @ 11/16/2009Pacific
As a temporary work around, the performance issue can be resolved by adding the directory, wp-content/uploads/dm-albums/. Once we have full functionality verified on WAMP, we will be issuing an update with full WAMP support.

5 Responses to “DM Albums™ and WAMP Fatal Error”

  1. evert says:

    I had te same fatal error. After changing the first line in includes.php I did not get an error anymore. I can see DM-Albums after activating. But DM-Albums seems to slow donw the loading of my entire website, especially de admin part, somethings hangs! If I de-activate DM-Albums my website speeds up again. Can you help me pls?

  2. frank says:

    @evert:
    Thanks for writing. I am able to reproduce this on my local WAMP development environment, but not anywhere else. Also, the WAMP user who originally reported the problem did not experience any performance problems.

    We appreciate your patience while we continue to work to resolve the problem. Thanks!

  3. frank says:

    @evert:
    UPDATE: As a temporary work around, the performance issue can be resolved by adding the directory, wp-content/uploads/dm-albums/. Once we have full functionality verified on WAMP, we will be issuing an update with full WAMP support.
    Thanks.

  4. On an unrelated note, when I try to upload new images into a new album using DM Albums I get an “upload error 403″

  5. frank says:

    @John Crumpton
    Are you talking about WAMP specifically, or is this on a non-WAMP installation?

    We’ve managed to get a number of other items off the list and can spend some more time trying to refine some WAMP issues, so any more information you have to point at us would be greatly appreciated.

Leave a Comment