This is to document the mods made to the original [[http://www.minigal.dk/minigalnano/|MiniGal Nano]] ver 0.3.5\\

It hasn't been updated in a long time and even the website is down (above link is to the demo))\\
There have been forks made of it (one in GitHub) where some improvements were made\\
  *Remove the check code
  *Cache the thumbnails
  *Allow each folder to have a comment under the breadcrumbs
  *etc

I looked through these but first here are the mods I had to make to get the initial code work with my website..\\

**Modify the integrate.html template**\\
This template is a full webpage, and thus cannot be inserted into an existing webpage.\\
Remove the code down to the ''%%<body>%%'' tag and the ending ''%%</body>%%'' downwards.\\
Also useful to put a link tag across the ''%%<% title %>%%'' template tag.\\

**Remove the error in index.php**\\
This error prevents the ''folder.jpg'' in the embedded gallery from showing.\\
In line ''164'' of ''index.php'', change the ''$currentdir'' to ''$thumbdir'' so ''createthumb.php'' can find the ''folder.jpg'' file.\\

**Remove the check code**\\
Basically comment out line ''129'' to ''136''\\

//Note:// In the original ''index.php'' we have (lines 138 to 141)
<code>
if (!defined("GALLERY_ROOT")) define("GALLERY_ROOT", "");
$thumbdir = rtrim('photos' . "/" .$_REQUEST["dir"],"/");
$thumbdir = str_replace("/..", "", $thumbdir); // Prevent looking at any up-level folders
$currentdir = GALLERY_ROOT . $thumbdir;
</code>

but this has been replaced by ''Sébastien SAUVAGE'' to
<code>
if (!defined("GALLERY_ROOT")) define("GALLERY_ROOT", "");
$requestedDir = '';
if (!empty($_GET['dir'])) $requestedDir = $_GET['dir'];
$thumbdir = rtrim('photos/'.$requestedDir,'/');

$thumbdir = str_replace('/..', '', $thumbdir); // Prevent directory traversal attacks.
$currentdir = GALLERY_ROOT . $thumbdir;
</code>
Why?\\

//End Note://

Now to put in some code so that a file ''comment.txt'' can be placed in the folder with some description of the pictures in the folder.\\

In the '' DEFINE VARIABLES'' section, add\\
<code>$comment = "";</code> after <code>$messages = "";</code>\\

Now for the actual code. //Sebsavage// puts it after the ''OUTPUT MESSAGES'' (''line 371'') but //Zulu// puts it in the ''READ FILES AND FOLDERS'' section (''after line 147'')\\

<code>
// LOAD FOLDER COMMENT FROM TEXT FILE (IF AVAILABLE)
$comment_filepath = $currentdir . "/comment.txt";
if (file_exists($comment_filepath)) {
 $fd = fopen($comment_filepath, "r");
 $comment = utf8_encode(fread($fd,filesize ($comment_filepath))); // utf8_encode to convert from iso-8859 to UTF-8
 fclose($fd);
} 
</code>

** Change the getFileSize function**\\
The ''getFileSize'' function was failing on one server because it used ''exec'' in the code. So I replaced it with a similar function copied from the php.net website

<code>	
public static function getFileSize($file)
{
 $a = fopen($file, 'r'); 
 fseek($a, 0, SEEK_END); 
 $sizeInBytes = ftell($a); 
 fclose($a);

 return $sizeInBytes;
}
</code>