Development Blog

DM Albums™ and DM FileManager™ Service Releases December 1st, 2009

Productions has issued service releases for DM Albums™ and DM FileManager™ that addresses potential security risks and offer increased (although still beta) WAMP support.  Unfortunately we’ve had limited time available to work on these products and get them fully compatible with WAMP, but we are continuing to work on these issues.

Again, thanks for the continued efforts by Safety at nDarkness.com for his security testing efforts and reporting.  We will be continuing to work with the nDarkness team on a security re-architecture and issue a point release in the coming weeks.

Productions always recommends all users stay current with the latest releases in order to minimize any security risks.

DM FileManager™ Service Release November 20th, 2009

Productions has issued a service release for DM FileManager™ that addresses a potential security risk.  Thanks for the continued efforts by Safety at nDarkness.com for his security testing efforts and reporting.  We will be continuing to work with the nDarkness team on a security re-architecture and issue a point release in the coming weeks.  In the meantime, Productions recommends all users upgrade to the current release.

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.

DM Albums™ External Usage Update November 4th, 2009

In order to make it easier to use DM Albums™ outside your WordPress blog, the Productions has released a new file to the DM Albums™ project called dm-albums-external.php which does all the setup discussed in the article about using DM Albums™ outside your blog.  This file will be available as part of the DM Albums™ distribution starting with v2.3.2 (not yet released as of this writing), but for those of you who want to start using this file now, you can download it and copy it into your dm-albums plugin folder.

dm-albums-external.php does all the setup required for connecting to WordPress and provides a functions called printalbum which makes the call to the plugin function to display the album.   The function definition is:

function dm_printalbum($directory)

The only parameter is $directory which is the filesystem path to your album, relative to your Home Folder setting.  (If you use the absolute path, that’s OK because the printalbum function will fix that for you.)

All you have to do is to include the dm-albums-external.php file into your php script, and call dm_printalbum whereever you’d like to show the album.

Your code should look something like this (you would have to modify your include path to point at the dm-albums-external file correctly):

<?php

include($_SERVER["DOCUMENT_ROOT"] . “/wp-content/plugins/dm-albums/dm-albums-external.php”);

dm_printalbum(“/wp-content/plugins/dm-albums/preview/”);

?>

» View the Demo.

dm-albums-external.php

DutchMonkey Development Blog November 3rd, 2009

Productions has launched the Development Blog. This blog is intended to serve as a central location for general support for products. We’ll be posting news and support information here, so check back regularly.

We would also like to thank the community for the wonderful feedback on the latest release of DM Albums. Community involvement and collaboration is what makes the open-source movement a rewarding and productive forum for development.