###############################################################################
# BizDesign ImageFolio Lite Edition 4.2 (Four-dot-Two)
###############################################################################
#
#          ##          ###        VERSION       :  4.2
#        ####        ##   ##      RELEASED ON   :  02/15/2007
#      ##  ##              ##     LAST MODIFIED :  02/15/2007
#    ##########          ##       
#          ##   ###    ##         
#          ##   ###  ########     
#
###############################################################################
# Released by BizDesign, Inc.
# written by Dirk Koppers and Greg Raaum of BizDesign
#
# Purchasing :  http://imagefolio.com/purchase/
# Support    :  http://imagefolio.com/support/
# Phone      :  (214) 642-9787
# Email      :  sales@bizdesign.com
###############################################################################
# COPYRIGHT AND LICENSE INFORMATION :
#
# Copyright (c) 1999-2007 BizDesign, Inc. All rights reserved.
#
# Selling or distributing the code for this program without prior written
# consent is expressly forbidden.
#
# One licensed copy of the program may reside on a single server, in use by a
# single domain.  For each installed instance of the program, a separate
# license is required.
#
# Licensed users may alter or modify this software, at their own risk, of
# course.  They may also hire others to modify their own copy of the code, as
# long as the code is not transferred to or retained by the individual who is
# hired (unless he/she is also a license holder). Although license-holders
# may modify the code for their use, modified code may NOT be resold or
# distributed.
#
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BIZDESIGN,
# INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# BizDesign, Inc. is not liable for any conduct associated with image gallery
# activity, nor for any binary media posted using this program, including but
# not imited to images, photographs, movies, and clipart.
#
# The user must assume the entire risk of using the program.  Although this
# program has been thoroughly tested on BizDesign's servers, BizDesign does not
# warrant that it works on all servers and will not be held liable for anything,
# including but not limited to, misusage, error, or loss of data.  ANY
# LIABILITY OF THE SELLER WILL BE LIMITED EXCLUSIVELY TO PRODUCT REPLACEMENT
# OR REFUND OF PURCHASE PRICE.  Use at your own risk!
###############################################################################
# Do not modify below this line unless you know what you are doing.
###############################################################################
use HTML::Entities;

sub headerfooter {
	my $cancel = $FORM{'cancel'};

	if ($cancel) {
	       require "$admindir_directory/config_editor.pl";

	       &menu;
	}

	my $section = $FORM{'section'};

	&Error('You may only edit the header or footer') if $section ne 'header' && $section ne 'footer';

	my $update = $FORM{'update'};

	my $admin_area_html_data = $FORM{'admin_area_html_data'};

	if (defined($admin_area_html_data) && $update) {
		$admin_area_html_data =~ s/\r\n/\n/g;

		if ($section eq 'header') {
			$imagefolio_header_html = $admin_area_html_data;
		} elsif ($section eq 'footer') {
			$imagefolio_footer_html = $admin_area_html_data;
		}

		my $write = '$imagefolio_header_html = qq{' . "\n" . $imagefolio_header_html . "\n" . '};' . "\n\n";
		$write   .= '$imagefolio_footer_html = qq{' . "\n" . $imagefolio_footer_html . "\n" . '};' . "\n";
		
		unless ($admin_demo_mode) {
			open(FILE, ">$data_directory/config/headerfooter.pl");
			flock(FILE, 2) if $useflock;
			print FILE "$write\n1;";
			flock(FILE, 8) if $useflock;
			close(FILE);
			chmod(0777, ">$data_directory/config/headerfooter.pl");
		}

	       require "$admindir_directory/config_editor.pl";

	       &menu;
	}

	my $html;

	if ($section eq 'header') {
		$html = $imagefolio_header_html;
	} elsif ($section eq 'footer') {
		$html = $imagefolio_footer_html;
	}
	
	$html = encode_entities($html);

	&get_header;

	print qq{
<center>
<table border="0" width="100%" cellspacing=0 cellpadding=0 bgcolor="#000000">
  <tr>
    <td>
      <table border="0" width="100%" cellspacing=1 cellpadding=0>
        <tr bgcolor="#ffcc00">
          <td>
            <table border="0" width="100%" cellspacing=0 cellpadding=4>
              <tr>
                <td><$admin_big_font><b>ImageFolio Skins Manager</b></font></td>
                <td align=right><$admin_big_font><b>Template Editor</b></font></td>
              </tr>
            </table>
          </td>
        </tr>
        <tr bgcolor="#ffffff">
          <td valign=top>
            <table border=0 cellspacing=1 cellpadding=15 width="100%">
              <tr bgcolor="#eeeeee">
                <td bgcolor="#eeeeee" align="center">
                  <form method="post" action="$adminurl&cgi=headerfooter.pl" enctype="multipart/form-data">
                    <input type="hidden" name="admin" value="admin">
                    <input type="hidden" name="cgi" value="headerfooter.pl">
                    <input type="hidden" name="section" value="$section">
                    <input type="hidden" name="uid" value="$FORM{'uid'}">
                    <textarea class="object" style="width:100%" name="admin_area_html_data" rows="20" wrap="off">$html</textarea><br><br>
                    <input type="submit" name="update" value="Update Configuration"> &nbsp; <input type="submit" name="cancel" value="Cancel">
	          </form>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
	};

	&get_footer;
	
	exit;
}

1;
