Title: Photo Gallery v2.0

Author: Steven Waters, John Briggs

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

Description:
This mod will provide a photo gallery to your xmb board.
These instructions are for an upgrade from v1.1 or v1.2 of the Photo Gallery.

Copyright:  2006 XMBMods.com

Compatability: XMB 1.9.5 Final

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

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

Author Note:
Please feel free to improve this modification so long as you abide by the GNU GPL license and respect my copyrights.

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

    Copy all the php files from the Contents folder  EXCEPT for gallery_install.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:
=======

    Remove the existing gallery_functions.php file from your XMB folder.

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

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

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

    require ROOT."lang/English.gallery.php";

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

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

=====================
Find Code and Remove:
=====================

    require ROOT.'gallery_functions.php';

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

    $tables = array(

=============================
At the end of the line, find:
=============================

    );

====================
and replace it with:
====================

    , 'imgimagedata', 'imgthumbnails');

=======================================================================================================================
=======
Step 6:
=======
===================
Edit 'misc.php'
===================

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

    require "./header.php";

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

    require_once('include/gallery.functions.inc.php');

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

    global $db, $table_forums, $table_threads, $lang, $self;

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

    global $db, $table_forums, $table_threads, $lang, $self, $table_imgsettings, $table_imgcats, $table_imgimages;

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

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

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

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

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

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

    } else {
        $location = $url;
    }

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

    } elseif (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 $table_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 $table_imgcats 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';
                 }
            } elseif (false !== strpos($url, "/gallery.php")) {
                $location = $lang['img_onlineviewgallery'];
            } elseif (false !== strpos($url, "/gallery_view_album.php")  && gallery_viewalbumperm($cid)) {
                 $location = $lang['img_onlineviewalbum'].' '.$albumname[$cid];
            } elseif (false !== strpos($url, "/gallery_user_album.php") && gallery_viewalbumperm($cid)) {
                if (false !== strpos($url, "create")) {
                    $location = $lang['img_onlineaddalbum'];
                } elseif (false !== strpos($url, "edit")) {
                    $location = $lang['img_onlineeditalbum'].' '.$albumname[$cid];
                } elseif (false !== strpos($url, "delete")) {
                    $location = $lang['img_onlinedeletealbum'].' '.$albumname[$cid];
                }
            } elseif (false !== strpos($url, "/gallery_image.php") && gallery_viewalbumperm($cid)) {
                if (false !== strpos($url, "add")) {
                    $location = $lang['img_onlineaddimage'].' '.$albumname[$cid];
                } elseif (false !== strpos($url, "upload")) {
                    $location = $lang['img_onlineuploadimage'].' '.$albumname[$cid];
                } elseif (false !== strpos($url, "edit")) {
                    $location = $lang['img_onlineeditimage'].' '.$imagename[$iid];
                } elseif (false !== strpos($url, "delete")) {
                    $location = $lang['img_onlinedeleteimage'].' '.$imagename[$iid];
                }
            } elseif (false !== strpos($url, "/gallery_comments.php") && gallery_viewalbumperm($cid)) {
                if (false !== strpos($url, "reply")) {
                    $location = $lang['img_onlinereplycomment'].' '.$imagename[$iid];
                } elseif (false !== strpos($url, "edit")) {
                    $location = $lang['img_onlineeditcomment'].' '.$imagename[$iid];
                }
            } elseif (false !== strpos($url, "/gallery_stats.php")) {
                $location = $lang['img_onlineviewstatus'];
            } elseif (false !== strpos($url, "/gallery_search.php")) {
                $location = $lang['img_onlinesearch'];
            }
        }
    } else {
        $location = $url;
    }

=======================================================================================================================
=======
Step 7:
=======

    Run gallery_upgrade.php, and follow the prompts.

    Delete gallery_upgrade.php and img_templates.xmb after installation.

=======================================================================================================================
=======
Step 8:
=======

    You may, if you wish, delete the upload folder and it's contents that was created for the prior versions of the Gallery.
    They are no longer required by the Gallery.

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