=======================================================================================================================================
Mod Title: Photo Gallery

Mod Version: 2.0

Mod Author: Steven Waters, John Briggs

Mod Contributors: Jack Faxon, Stalker, Spike, Bigdumredneck, Elmo

Mod Description:
This mod will provide a photo gallery to your eXtreme Message Board.

Mod Copyright:  2005-2008 XMBMods.com. All rights reserved.

Mod Compatibility: XMB 1.9.8 Engage Final SP2

Mod Install Note: Before adding this mod to your forum, you should back up all files related to this mod.

Mod License Note: This mod is released under the GPL v3 License. A copy is provided with this software.

Mod Author Note:
This modification is developed and released for use with XMB 1.9.8 Engage Final SP2 which is provided by XMBMods.com.

=======================================================================================================================================
=======
Step 1:
=======

Copy all the php files from the Contents folder EXCEPT for gallery_upgrade.php and gallery.function.inc.php to your XMB folder.
Copy the img_templates.xmb file to your XMB folder.

=======================================================================================================================================
=======
Step 2:
=======

Copy the contents of the Gallery lang folder to your XMB lang folder.

=======================================================================================================================================
=======
Step 3:
=======

Copy gallery.function.inc.php to your Include folder

=======================================================================================================================================
=======
Step 4:
=======

Copy the '.gif' files from the images folder to your theme folders

=======================================================================================================================================
=======
Step 5:
=======

===================
Edit 'header.php'
===================

==========
Find Code:
==========

if (file_exists(ROOT.'lang/'.$langfile.'.lang.php')) {
    require ROOT.'lang/'.$langfile.'.lang.php';
} else {
    require ROOT.'lang/English.lang.php';
}

===============
Add Code Below:
===============

if (file_exists(ROOT.'lang/'.$langfile.'.gallery.php')) {
    require_once(ROOT.'lang/'.$langfile.'.gallery.php');
} else {
    require_once(ROOT.'lang/English.gallery.php');
}

==========
Find Code:
==========

    'forums',

===============
Add Code Below:
===============

    'imgcats',
    'imgcomments',
    'imgimages',
    'imgimagedata',
    'imgsettings',
    'imgthumbnails',
    'imgvotes',

==========
Find Code:
==========

$links = implode(' &nbsp; ', $links);

==========
Add above:
==========

$links[] = '<img src="'.$imgdir.'/camera.gif" alt="'.$lang['img_textphotogallery'].'" border="0" /> <a href="gallery.php"><font class="navtd">'.$lang['img_textphotogallery'].'</font></a>';

=======================================================================================================================================
=======
Step 6:
=======

================================
Edit File: include/admin.inc.php
================================

==========
Find Code:
==========

        $this->fix_last_posts();

===============
Add Code Above:
===============

        // Update the images, albums and votes.
        $db->query("UPDATE ".X_PREFIX."imgimages SET author='$userto' WHERE author='$userfrom'");
        $db->query("UPDATE ".X_PREFIX."imgcats SET author='$userto' WHERE author='$userfrom'");
        $db->query("UPDATE ".X_PREFIX."imgvotes SET username='$userto' WHERE username='$userfrom'");

        // Update the last post in the albums
        $query = $db->query("SELECT cid, lastpost from ".X_PREFIX."imgcats WHERE lastpost like '%$userfrom'");
        while($result = $db->fetch_array($query)) {
            list($posttime, $lastauthor) = explode('|', $result['lastpost']);
            if ($lastauthor == $userfrom) {
                $newlastpost = $posttime.'|'.$userto;
                $db->query("UPDATE ".X_PREFIX."imgcats SET lastpost='$newlastpost' WHERE cid='".$result['cid']."'");
            }
        }
        $db->free_result($query);

        // Update the view list for the albums
        $query = $db->query("SELECT view_list, cid FROM ".X_PREFIX."imgcats WHERE (view_list REGEXP '(^|(,))( )*$userfrom( )*((,)|$)')");
        while($list = $db->fetch_array($query)) {
            $parts = explode(',', $list['view_list']);
            $index = array_search($userfrom, $parts);
            $parts[$index] = $userto;
            $parts = implode(', ', $parts);
            $db->query("UPDATE ".X_PREFIX."imgcats SET view_list='".$parts."' WHERE cid='".$list['cid']."'");
        }
        $db->free_result($query);

        // Update the add list for the albums
        $query = $db->query("SELECT add_list, cid FROM ".X_PREFIX."imgcats WHERE (view_list REGEXP '(^|(,))( )*$userfrom( )*((,)|$)')");
        while($list = $db->fetch_array($query)) {
            $parts = explode(',', $list['add_list']);
            $index = array_search($userfrom, $parts);
            $parts[$index] = $userto;
            $parts = implode(', ', $parts);
            $db->query("UPDATE ".X_PREFIX."imgcats SET add_list='".$parts."' WHERE cid='".$list['cid']."'");
        }
        $db->free_result($query);

=======================================================================================================================================
=======
Step 7:
=======
===================
Edit File: misc.php
===================

==========
Find Code:
==========

require 'header.php';

===============
Add Code Below:
===============

require ROOT.'include/gallery.functions.inc.php';

=======================================================================================================================================
=======
Step 8:
=======
=================================
Edit File: include/online.inc.php
=================================

==========
Find Code:
==========

    static $restrict, $rset, $fname, $tsub;

==================
Replace Code With:
==================

    static $restrict, $rset, $fname, $tsub, $albumname, $imagename;

    $query = $db->query("SELECT who_view_gallery FROM ".X_PREFIX."imgsettings");
    $who_view_gallery = $db->result($query, 0);
    $db->free_result($query);

==========
Find Code:
==========

    } else {
        $location = $lang['onlineindex'];
    }

=============
Replace with:
=============

    } else if (false !== strpos($url, 'gallery')) {
        if (privfcheck($who_view_gallery,'')) {
            if (false !== strpos($url, 'cid')) {
                $temp = explode('?', $url);
                $urls = explode('&', $temp[1]);
                foreach($urls as $key=>$val) {
                    if (strpos($val, 'cid') !== false) {
                        $cid = (int) substr($val, 4);
                    }
                }

                if (!isset($albumname[$cid])) {
                    $query = $db->query("SELECT name FROM ".X_PREFIX."imgcats WHERE cid='$cid'");
                    while($locate = $db->fetch_array($query)) {
                        $albumname[$cid] = $locate['name'];
                    }
                    $db->free_result($query);
                }
            }

            if (false !== strpos($url, 'iid')) {
                $temp = explode('?', $url);
                $urls = explode('&', $temp[1]);
                foreach($urls as $key=>$val) {
                    if (strpos($val, 'iid') !== false) {
                        $iid = (int) substr($val, 4);
                    }
                }

                if (!isset($imagename[$iid])) {
                    $query = $db->query("SELECT name FROM ".X_PREFIX."imgimages WHERE iid='$iid'");
                    while($locate = $db->fetch_array($query)) {
                        $imagename[$iid] = $locate['name'];
                    }
                    $db->free_result($query);
                }
            }

            if (false !== strpos($url, '/gallery_admin.php')) {
                $location = $lang['img_onlinecp'];
                if (!X_ADMIN) {
                    $url = 'index.php';
                 }
            } else if (false !== strpos($url, '/gallery.php')) {
                $location = $lang['img_onlineviewgallery'];
            } else if (false !== strpos($url, '/gallery_view_album.php')  && gallery_viewalbumperm($cid)) {
                 $location = $lang['img_onlineviewalbum'].' '.$albumname[$cid];
            } else if (false !== strpos($url, '/gallery_user_album.php') && gallery_viewalbumperm($cid)) {
                if (false !== strpos($url, 'create')) {
                    $location = $lang['img_onlineaddalbum'];
                } else if (false !== strpos($url, 'edit')) {
                    $location = $lang['img_onlineeditalbum'].' '.$albumname[$cid];
                } else if (false !== strpos($url, 'delete')) {
                    $location = $lang['img_onlinedeletealbum'].' '.$albumname[$cid];
                }
            } else if (false !== strpos($url, '/gallery_image.php') && gallery_viewalbumperm($cid)) {
                if (false !== strpos($url, 'add')) {
                    $location = $lang['img_onlineaddimage'].' '.$albumname[$cid];
                } else if (false !== strpos($url, 'upload')) {
                    $location = $lang['img_onlineuploadimage'].' '.$albumname[$cid];
                } else if (false !== strpos($url, 'edit')) {
                    $location = $lang['img_onlineeditimage'].' '.$imagename[$iid];
                } else if (false !== strpos($url, 'delete')) {
                    $location = $lang['img_onlinedeleteimage'].' '.$imagename[$iid];
                }
            } else if (false !== strpos($url, '/gallery_comments.php') && gallery_viewalbumperm($cid)) {
                if (false !== strpos($url, 'reply')) {
                    $location = $lang['img_onlinereplycomment'].' '.$imagename[$iid];
                } else if (false !== strpos($url, 'edit')) {
                    $location = $lang['img_onlineeditcomment'].' '.$imagename[$iid];
                }
            } else if (false !== strpos($url, '/gallery_stats.php')) {
                $location = $lang['img_onlineviewstats'];
            } else if (false !== strpos($url, '/gallery_search.php')) {
                $location = $lang['img_onlinesearch'];
            }
        }
    } else {
        $location = $lang['onlineindex'];
    }

=======================================================================================================================================
=======
Step 9:
=======

Run gallery_install.php, and follow the prompts.

Delete gallery_install.php and img_templates.xmb after installation.

=======================================================================================================================================