Auto create gallery for JonDesign’s Smooth Gallery

This is something I wrote to make my life easier adding images on the JDGallery. It automatically scans the directory and creates the div section (where gallery and images are defined). Simply replace the following section.
<div class="content">
<div id="myGallerySet">
.....
</div>
</div>
with the output of the code below
<?php
$path = "gallery"; //path to scan for folders/images
 
//couple of things
//thumbnails must be named {filename}_thumb.{extension}
//extension of file is limited to 3 character like jpg, gif, not jpeg, etc.
//sorry, got no time to enhance it, so you can copy and modify as needed, it's free.
 
//using the opendir function
$dir_handle = @opendir($path) or die("Unable to open $path");
 
echo "Copy Paste the code below.<br><br>";
echo "<tt>&lt;div class="content"&gt;<br>&lt;div id="myGallerySet"&gt;<br><br>";
 
list_dir($dir_handle,$path);
 
echo "&lt;/div&gt;<br>&lt;/div&gt;</tt>";
 
function list_dir($dir_handle,$path)
{
	$countgallery = 1;
	$countimages = 1;
 
	//running the while loop
    while (false !== ($file = readdir($dir_handle))) {
        $dir =$path.'/'.$file;
		if(is_dir($dir) && $file != '.' && $file !='..' )		
        {
			$handle = @opendir($dir) or die("unable to open file $file");
			echo "&lt;div id="gallery$countgallery" class="galleryElement"&gt;<br>&lt;h2&gt;$file&lt;/h2&gt;<br><br>";
            list_dir($handle, $dir);
			echo "&lt;/div&gt;<br><br>";
			$countgallery++;
			$countimages = 1;
        }
 
		elseif($file != '.' && $file != '..' && substr($dir, -9, 5) != 'thumb')
        {
			$mainfilename = $dir;
			$thumbfilename = substr($dir, 0, -4) . "_thumb.jpg";
			echo "&lt;div class="imageElement"&gt;<br>&lt;h3&gt;Item $countimages Title&lt;/h3&gt;<br>&lt;p&gt;Item $countimages Description&lt;/p&gt;<br>&lt;a href="#" title="open image" class="open"&gt;&lt;/a&gt;<br>&lt;img src="$mainfilename" class="full" /&gt;<br>&lt;img src="$thumbfilename" class="thumbnail" /&gt;<br>&lt;/div&gt;<br>";
			$countimages++;
        }
    }   
 
    //closing the directory
    closedir($dir_handle);
}
?>
FacebookTwitterGoogle+Share

Max pool .NET issue on ADO.NET and a quick solution

This is the error message you will get when pool is maxed out. Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. Please try closing reader, command, connection by using close() and dispose() before using the method below. If the pooling is enabled in the application, sometime closing the connection by using Dispose() or Close() is just going to put the connection on the sleep mode (awaiting command). Even though there is connection closing statements on the application, on the database side, it was putting those connections on the sleep mode. As it built up, there were no more pool left, therefore it timed out. Solution is to add Pooling = False on the connection string of the application. This closes the connection as soon as dispose() is introduced. Hence no timeouts waiting for open pool.
Database=testdb; Server=testserver; uid=test; PWD=test; Pooling=False; Connect Timeout=30
I am not responsible if you use my solution and mess up something. Do at your own risk. Works for me here. Checking number of connections on database to see if max pool has reached …
--Total number of connections
SELECT DB_NAME(dbid) AS 'Database Name',
COUNT(dbid) AS 'Total Connections'
FROM sys.sysprocesses WITH (nolock)
WHERE dbid > 0
GROUP BY dbid;
 
--Connections
SELECT hostname, program_name, STATUS, cmd FROM sys.sysprocesses
WHERE DB_NAME(dbid) = 'Database Name goes here';