###############################################################################
# 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.
###############################################################################
$UPLOADFILES = "active";

###############################################################################
# UPLOAD IMAGE
# Here we upload an image to the image directory
###############################################################################

sub iBULC_iframe {
   &get_catlist;
   print "Content-type: text/html\n\n";
   print qq|<html><body bgcolor="#eeeeee">|;




   print qq|
   <form method="POST" action="$iBULC_uploaddurl">
   <center>
   <table>
   <tr><td nowrap align="center"><$admin_small_font><b>U P L O A D&nbsp;&nbsp;&nbsp;L O C A T I O N</b></font></td></tr>
   <tr><td align="center">$catlist</td></tr></table>


   <br><input type=submit value="Upload Files">
   </center>
   </form>
   |;



   print "</body></html>";
   exit;
}

sub upload_image {

$pagetitle = "Upload Files";
&get_header;
&get_catlist;

# &find_images; #NOT needed at the moment. Will be usefull when we integrate it into UBB or
# IKON BOARD since the administrator can the set $max_upload_per. Since this is not integrated yet
# we set:
$Number_Files = 0;
$max_upload_per = 1;



   $ucount = 1;

   while ($ucount != 4) {
      if ($FORM{"image$ucount"}) {
         if (!$run_once) {
            $run_once = 1;
            $comment = qq|<$admin_font><b>The following files were upload and renamed if necessary:<br>|;
         }
         $comment .= qq|- <font color=red>$FORM{"image$ucount"}</font><br>|;
      }
      $ucount++;
   }
   if ($run_once) {
      $comment .= qq|to the category: <font color=red>$FORM{'savecat'}</font></b></font>|;
   }

print qq|$comment|;

if (!$iBULC_upload) {

   if ($use_single_file_upload) {
      print qq|<form method="POST" action="$imuploaddurl" ENCTYPE="multipart/form-data">|;
      $imalign = " align=center";
   }
   else {
      print qq|<form method="POST" action="$uploadurl" ENCTYPE="multipart/form-data">|;
      $noimcolspan = " colspan=2";
   }

   print qq|
   <input type=hidden name=uid value="$FORM{'uid'}">


   <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$noimcolspan>
   <table border="0" width="100%" cellspacing=0 cellpadding=4>
   <tr><td><$admin_big_font><b>Upload Files</b></font></td>
   <td align=right><$admin_big_font><b>Step 1
   of 1</b></font></td> </tr></table></td></tr>

   <tr bgcolor="#eeeeee">|;

   if ($use_single_file_upload) {

      if ($use_fullsize) {
         $temp_extension = lc($myextension_fullsize);
      }
      else {
         $temp_extension = "jpg</font> or <font color=red>tif";
      }

      my $media_text = qq| (Must be a <font color=red>$temp_extension</font> image!)|;

      print qq|<td valign=top>
      <table border=0 cellspacing=0 cellpadding=4 width="100%">
      <tr><td nowrap$imalign><$admin_small_font><b>U P L O A D&nbsp;&nbsp;F I L E</b>$media_text</font></td></tr>
      <tr><td$imalign><input type="file" name="FILE1" size=40></td></tr>|;
   }

   else {
      print qq|
      <td width="50%" valign=top>
      <table border=0 cellspacing=0 cellpadding=4 width="100%">

      <tr><td nowrap><$admin_small_font><b>L I N K E D&nbsp;&nbsp;;F I L E</b></font></td></tr>
      <tr><td><input type="file" name="FILE1" size=40></td></tr>

      <tr><td nowrap><$admin_small_font><b>T H U M B N A I L&nbsp;&nbsp;&nbsp;I M A G E</b> (Must be a <font color=red>jpg</font> image!)</font></td></tr>
      <tr><td><input type="file" name="FILE2" size=40></td></tr>|;

   if ($use_fullsize) {
      my $temp_extension = lc($myextension_fullsize);
      print qq|
      <tr><td nowrap><$admin_small_font><b>F U L L&nbsp;&nbsp;S I Z E&nbsp;&nbsp;D O W N L O A D&nbsp;&nbsp;F I L E</b> (Must be had a <font color=red>$temp_extension</font> file!)</font></td></tr>
      <tr><td><input type="file" name="FILE3" size=40></td></tr>|;
   }

   print qq|</table>

      </td><td valign=top>
   <table border=0 cellspacing=0 cellpadding=4 width="100%">|;
   }



   print qq|
   <tr><td nowrap$imalign><$admin_small_font><b>U P L O A D&nbsp;&nbsp;L O C A T I O N</b></font></td></tr>
   <tr><td$imalign>$catlist</td></tr></table>

   </td></tr></table>

   </td></tr></table>
   <br><input type=submit value="Upload Files">
   </center>
   </form>
   |;
}

else {
      print qq|
<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$noimcolspan>
<table border="0" width="100%" cellspacing=0 cellpadding=4>
<tr><td><$admin_big_font><b>Upload Files</b></font></td>
<td align=right><$admin_big_font><b>Step 1
of 1</b></font></td> </tr></table></td></tr>

<tr bgcolor="#eeeeee"><td align=center><IFRAME width="500" height="480" src="$adminurl&uid=$FORM{'uid'}&cgi=images.pl&imgaction=iBULC_iframe" scrolling="yes"></IFRAME></td></tr></table>

</td></tr></table>


|;
}

&get_footer;
}

1;

sub find_images {
@directories = "$image_directory/$usercat";
$totaldir = 1;
$slash = '/';

for ($i=0; $i<$totaldir; $i++) {
   $directory = @directories[$i];
   opendir(DIR,$directory);
   @listings = readdir(DIR);
   closedir(DIR);

   foreach $listing (@listings) {
      next if (($listing eq ".") or ($listing eq "..") or ($listing =~ /_vti_cnf/i) or ($listing =~ /$mypattern/i) or ($listing =~ /index.html/i));
      $fullpath = $directory . $slash . $listing;
      if (-d $fullpath) {
         push(@directories,$fullpath);
         $totaldir++;
      }
      else { 
         push(@THUMBS,$fullpath);
      }
   }
}

$Number_Files = @THUMBS;
}