Home
About Me!
Projects
Research
Links
Gallery
Travel
   
Random Header Image
Disable Enable
More Info



Photo Gallery

Overview:
I wanted to install a gallery on my website which would offer many features such as user logins, be easy to maintain, and hold the original photos on my home web server whilst be able to mirror resized photos to other servers.

The Chosen Solution:
I chose to use the open source php gallery software version 1.4.4 together with a patch created by Harry Otten for the extended mirroring functions which I altered slightly to give the features I required. These features were:

  • Full-size images (as in full resolution) are always loaded from master server.
  • All images are from master server if client is on local LAN. After looking at the smart mirror code it appears to include this option.

I also want to mirror the whole gallery excluding original jpegs in case my home web server goes down. I have tried copying gallery to another server to be used as a mirror however since the URL saved in the config points to the original server it does not work properly (because as soon as you click on a link it takes you back to the original server). Perhaps when using mirrors (with smart mirror) it will work ok. I have yet to test this.

Updates to Smart Mirror:
I have updated the patch by Harry Otten so that it always loads the original photos from the master server.

Alterations to the code:

Display original photos from master server only:

getPhotoTag function in classes/Album.php (line 1248)

replace:

return $photo->getPhotoTag($this->getAlbumDirURL("full"), $full);

with:

if ($full==1){
	return $photo->getPhotoTag($this->getAlbumDirURL("orig"), $full);
	}
	else {
		return $photo->getPhotoTag
		               ($this->getAlbumDirURL("full"), $full);
	}
}

getGoodMirrorUrl function in classes/MirrorManager.php (line 96)

insert:

/* Use master server for original photos */
if ($type=="orig")
	return;

also change _pickServer function at line 132 to:

function _pickServer($type) {
	if ($type == "full" || $type == "orig" || $type == "highlight"
	              || $type=="real_full" || $type=="movie") {
		// random
		$random = rand(0,sizeOf($this->cachedMirror)-1);
		return $this->cachedMirror[$random];
	} else {
		$this->roundRobin = ($this->roundRobin + 1) %
		                     sizeOf($this->cachedMirror);
		return $this->cachedMirror[$this->roundRobin];
	}
}

To allow all computer on the local LAN to only use the local server:

Locate the _localNetworkClient function in classes/MirrorManager.php (line 69) and change to:

function _localNetworkClient($ip) {
	if (ereg("192.168.", $ip))
		return true;
	return false;
}

(This assumes your LAN IP addresses start with 192.168.)


Allow for the html_wrap header and footer to test whether the photo is being displayed full size:

Change line 298 of view_photo.php to:

include ("html_wrap/photo.header");

instead of:

includeHtmlWrap("photo.header");

Change line 723 of view_photo.php to:

include("html_wrap/photo.footer");

instead of

includeHtmlWrap("photo.footer");

Now you can reference $full from the php code within the html_wrap/photo.header and html_wrap/photo.footer files.



Mirrored.txt Info:
To generate a time for the mirrored.txt file use the following command on a linux box:

date +%s

Future enhancements:
Display thumbnails from the mirror only for the albums it has listed. Perhaps check to see whether thumbnail exists on mirror, or look at list in mirrored.txt. Currently the system will display a broken image if the thumbs are not on mirror and if allthumbs:true is in mirrored.txt. I would like more control so I can specify that not all thumbs are on the mirror, but only the ones for which it lists the albums for. This behaviour could be implented if allthumbs:some.

Synchronise Software:
I would like to create intelligent synchronise software for gallery so that it is possible to easily update mirrors. The software would keep original images on the local server and not copy them to mirror servers. Using this synchronising software together with an adapted version of smart mirror (so that full size images are always loaded from the local server) would result in a good solution. Here are some ideas:

  • List albums on each server and highlight which albums are new on each. Show when each album last changed and size of dat file and allow overwrite from one server to the other in either direction. When overwriting only copy files that have changed or if not possible allow option of only overwriting dat files.
  • Do not copy original images from local server to online server.
  • albumdb.dat copied from local server, so local server should include all albums.
  • Allow overwrite of user information from local server to online server - therefore changes to users should only done on local server and then updated to online server.
  • Change mirror function so that original images are only displayed from local server.
  • Make sure write permissions are set on .dat files and that ordering of albums is correct once transferred.