TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

March 29, 2024, 09:48:34 AM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,106
  • Total Topics: 21,213
  • Online today: 358
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 92
  • Total: 92

My Gallery Code

Started by SniffTheGlove, September 27, 2006, 10:01:55 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

SniffTheGlove

Hi, after posting my site to the showcase forum I have been sent several PM's about the code, so I am posting it here for all to see/modify.

This code currently runs on my Win2k server which runs Apache 2.0.55, PHP 5.1.2 with GD2 so I can not say it will run fine on any other configuration.

Files are in the attached ZIP file.

So, here is what to do....

First, in your root folder create a folder called albumimages.

Unzip the files into your root folder.
Change the MySQL details in the midlandrocketry_db.inc
If you want to change the midlandrocketry_db.inc filename with one that reflects your site then you also have to change all the requires in the gallery files to the same name.
Change the details in the pg_copyright.inc to suit your own.


Create 4 articles in TP in a new category called Photo Gallery
Article 1) View Album - pg_albums.php
Article 2) Upload Photo - pg_uploadphoto.php
Article 3) Upload Video - pg_uploadvideo.php
Article 4) Search Albums - pg_albumsearch.php

Copy the following IFRAME code into each article, replacing ********** in the last line of code with the pg_******.php file in the article description above, so for View Albums replace ********** with pg_albums.php

This is a dynamic resizing IFRAME code


<script type="text/javascript">

/***********************************************
* IFrame SSI script II- ÂÃ,© Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use
***********************************************/

//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["myframe"]

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller() {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){
if (document.getElementById)
resizeIframe(iframeids[i])
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
tempobj.style.display="block"
}
}
}

function resizeIframe(frameid){
var currentfr=document.getElementById(frameid)
if (currentfr && !window.opera){
currentfr.style.display="block"
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight;
else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
if (currentfr.addEventListener)
currentfr.addEventListener("load", readjustIframe, false)
else if (currentfr.attachEvent){
currentfr.detachEvent("onload", readjustIframe) // Bug fix line
currentfr.attachEvent("onload", readjustIframe)
}
}
}

function readjustIframe(loadevt) {
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot)
resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url){
if (document.getElementById)
document.getElementById(iframeid).src=url
}

if (window.addEventListener)
window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
window.attachEvent("onload", resizeCaller)
else
window.onload=resizeCaller

</script>

<iframe id="myframe" src="**********" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" style="overflow:visible; width:100%; display:none"></iframe>





Create a Block and make it an Article Category and to show the Photo Galley





Run this SQL script to create the MySQL databases


-- phpMyAdmin SQL Dump
-- version 2.8.0.3
-- http://www.phpmyadmin.net
--
-- Host: 192.168.0.5
-- Generation Time: Sep 27, 2006 at 09:17 AM
-- Server version: 4.1.7
-- PHP Version: 5.1.2
--
-- Table structure for table `albumfiles`
--

DROP TABLE IF EXISTS `albumfiles`;
CREATE TABLE IF NOT EXISTS `albumfiles` (
  `AlbumFilesID` smallint(6) NOT NULL auto_increment,
  `AlbumID` smallint(6) NOT NULL default '0',
  `AlbumThumbnail` varchar(200) NOT NULL default '',
  `AlbumPhoto` varchar(200) NOT NULL default '',
  `AlbumPhotoDescription` varchar(255) NOT NULL default '',
  `AlbumPhotoCopyright` varchar(100) NOT NULL default '',
  `LoggedInAs` varchar(100) NOT NULL default '',
  `IPAddress` varchar(15) NOT NULL default '',
  `IPName` varchar(150) NOT NULL default '',
  `AlbumUploadDate` date NOT NULL default '2000-01-01',
  `UserAgent` varchar(150) NOT NULL default '',
  `AlbumFileViewed` int(11) NOT NULL default '1',
  PRIMARY KEY  (`AlbumFilesID`),
  KEY `AlbumID` (`AlbumID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

--
-- Table structure for table `albumfolder`
--

DROP TABLE IF EXISTS `albumfolder`;
CREATE TABLE IF NOT EXISTS `albumfolder` (
  `AlbumID` smallint(6) NOT NULL auto_increment,
  `AlbumName` char(50) NOT NULL default '',
  `AlbumDescription` char(200) NOT NULL default '',
  `AlbumDisplayDate` date NOT NULL default '0000-00-00',
  PRIMARY KEY  (`AlbumID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;

INSERT INTO `albumfolder` VALUES (1, 'Test Area', 'Test Area. Do your testing here first to get use to things', '1999-01-01');




To add additional Albums, I have always used phpMyAdmin to created the record manually as I have not got round yet to create a page to add albums.

The security is to allow only those that are logged in to upload anything, whereas everyone can view/search the albums.

The code intrgrated into a SMF/TP site can be found at http://www.midlandrocketry.org.uk and check the left hand blocks.

The code in a normal website can be seen at http://www.pigmasterrockets.com/albums.htm or http://www.rocketmotors.co.uk/albums.htm

SniffTheGlove

Sorry, forgot to say...

in the file pg_var.inc

the following settings

$columns = 3;
This indicate how many columns you want into the display.

$TopXViewed = 15;
This indicate how many views an image should have before appearing in to viewed pics






akulion


SniffTheGlove

Spent the day going over the code and I have changed it abit, took out redundant code etc.

I have added a create album page now and will rework the zip file and instructions after the weekend as I going away tomorrow for the weekend.

If anybody would like to see any additional features just add to this thread and I'll see what I can do.

Also as of tonight I will be removing the most of the test data from the albums, so if you want to see a lot of albums and pics look within the next 7 hours. This because the site will go live over the weekend and I don't want the test data there when people will start looking at the site in real time.

SniffTheGlove

I have done all the changes I wanted and they are all now in the gallery.zip file attached.

Changes I have made is that video's now play within the gallery and not via a standalone app, you can create Albums and the text sizes have been sorted out.

All details to install are in the readme.txt file (within the zip file), so extract all files into your SMF root folder and then follow the readme.

SniffTheGlove

What happens if you call pg_albums.php from the address bar, eg www.domain.com/pg_albums.php

SniffTheGlove

I am guessing that in your php block on the first line you may have
<------------------------------START OF CODE INSERT-------------------------------------------->

or at least a <

That is what you error code suggests

Parse error: syntax error, unexpected '<' Load.php(1723) : eval()'d code(229) : eval()'d code on line 1

SniffTheGlove

The articles are ordinary html articles and not php, try changing the Code modus in the article settings to be html.

I think that is where the problem is.

SniffTheGlove

The pg_******* pages, are they in your root folder, or elsewhere?


SniffTheGlove

OK, from your reply it seems that you are running the gallery php from the albumimages directory.

OK, then you will need to modify the requires in the pg_******* pages to reflect the location of the files, so I would guess that in your case you will need to change the require_once('SSI.php'); to require_once('./SSI.php');

I presume that the parent directory of albumimages is your root folder and in this folder should be ssi.php, so the above statement change should work, else just put the correct location instead of the ./