<?php
/*++++++++++++++++++++++++++++++++++++++++
Script: Maian Gallery v2.0
Written by: David Ian Bennett
E-Mail: hide@address.com
Website: http://www.maianscriptworld.co.uk
++++++++++++++++++++++++++++++++++++++++
This File: add_images.php
Description: Batch Add Images
++++++++++++++++++++++++++++++++++++++++*/
// Make sure that this file is being called from parent file
if (!defined('INCLUDE_FILES')) {
accessDenied($msg_script18,$msg_script19);
exit;
}
?>
<div align="center">
<table width="100%" border="0" cellpadding="0" cellspacing="1" style="border: 2px solid #083253">
<tr>
<td align="left" class="msgBox">» <b><?php echo $msg_adminmenu6; ?></b><br><br><?php echo $msg_addimg; ?></td>
</tr>
</table>
<?php
//Loop through images in images directory if any are present.
$images = array();
$dir = opendir(RELATIVE_PATH.'galleries/new');
while ($read = readdir($dir)) {
if ($read!='.' && $read!='..' && $read!=$SETTINGS->folder_name) {
$images[] = $read;
}
}
closedir($dir);
//Build category data. Assign data to single array instead of multiple db calls..
$cat_array = array();
$q_cats = mysql_query("SELECT * FROM ".$database['prefix']."categories
WHERE parent = '1'
ORDER BY catname
") or die(mysql_error());
while ($CATS = mysql_fetch_object($q_cats)) {
$cat_array[] = '<option value="{url}'.$CATS->id.'" style="padding-left:3px"'.(isset($_GET['cat']) && $_GET['cat']==$CATS->id ? ' selected="selected"' : '').'>'.cleanData($CATS->catname).'</option>'."\n";
// Does this category have children...
$q_children = mysql_query("SELECT * FROM ".$database['prefix']."categories
WHERE child = '{$CATS->id}'
ORDER BY catname") or die(mysql_error());
if (mysql_num_rows($q_children)>0) {
while ($CHILDREN = mysql_fetch_object($q_children)) {
$cat_array[] = '<option value="{url}'.$CHILDREN->id.'" style="padding-left:3px"'.(isset($_GET['cat']) && $_GET['cat']==$CHILDREN->id ? ' selected="selected"' : '').'>- '.cleanData($CHILDREN->catname).'</option>'."\n";
}
}
}
?>
<table cellpadding="0" cellspacing="0" width="100%" class="menutable">
<tr>
<td align="left" class="leftPad" width="50%" style="border-right:0">» <b><?php echo strtoupper($msg_addimg2); ?></b> (<?php echo count($images); ?>)</td>
<td align="right" class="leftPad" width="50%" style="border-left:0">[ <a href="javascript:window.location.reload(false);" title="<?php echo $msg_script21; ?>" style="color:#FFFFFF"><?php echo $msg_script21; ?></a> ]</td>
</tr>
</table>
<?php
if (count($images)>0)
{
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="margin-bottom:2px;background-color:#1EB5DD;border:1px solid #063052">
<tr>
<td align="center" colspan="2" style="padding:10px;"><b><?php echo $msg_addimg3; ?></b>:
<select onchange="if(this.value!= 0){location=this.options[this.selectedIndex].value}">
<option value="0">----</option>
<?php
//Show cats if any exist
if (count($cat_array)>0) {
foreach ($cat_array AS $cat_data){
echo str_replace("{url}","index.php?cmd=add_images&cat=",$cat_data);
}
}
?>
</select>
</td>
</tr>
</table>
<?php
}
?>
<form method="post" action="index.php?cmd=add_images" enctype="multipart/form-data" onsubmit="return delete_confirm('<?php echo $msg_javascript34; ?>')">
<input type="hidden" name="process" value="1">
<?php
//Are there any images in ecards directory?
if (count($images)>0)
{
//Loop through images to be added
$sale_count = 0;
$ok_types = explode("|", GD_EXTENSIONS);
foreach ($images AS $img_data)
{
$saleNo = $sale_count++;
// Only show images files..
if (in_array(strrchr(strtolower($img_data),"."),$ok_types) || strrchr(strtolower($img_data),".")=='.bmp')
{
?>
<input type="hidden" name="path[]" value="<?php echo $img_data; ?>">
<input type="hidden" name="isize[]" value="<?php echo filesize(RELATIVE_PATH.'galleries/new/'.$img_data); ?>">
<table width="100%" border="0" cellpadding="0" cellspacing="1" style="margin-bottom:5px;border: 2px solid #083253">
<tr>
<td align="left" valign="top" class="msgBox">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="left" width="15%" valign="top" style="border-right:1px dashed #FFFFFF">
<a href="index.php?cmd=cat_images&new_img=<?php echo $img_data; ?>" rel="gb_page_center[680, 540]" title="<?php echo $img_data; ?>"><img src="<?php echo $SETTINGS->folder; ?>/galleries/new/<?php echo $img_data; ?>" width="<?php echo ADD_IMG_WDTH; ?>" height="<?php echo ADD_IMG_HGHT; ?>" class="image_pad" border="1" alt="<?php echo $img_data; ?>" title="<?php echo $img_data; ?>"></a><br><br>
<?php echo showImgAttributes($img_data); ?>
</td>
<td align="left" width="85%" valign="top" style="padding-left:5px">
<table width="100%" border="0" cellpadding="0" cellspacing="2">
<tr>
<td align="left" class="tdHeight" width="20%"><b><?php echo $msg_addimg7; ?></b>:</td>
<td width="80%" align="left" class="tdHeight"><input type="text" name="name[]" maxlength="200" class="formbox"> * <i>(<?php echo $msg_script14.' 200 - '.$msg_addimg4; ?>)</i></td>
</tr>
<?php
// Is auto thumbnail creation enabled?
// If not, show field to upload thumbnail, else no field needed
// If auto thumbnail is enabled and file type is not supported, ie: .bmp
// force thumbnail upload box to show
// If gif support is not enabled, also show box
$extension = strrchr(strtolower($img_data),".");
if (!$SETTINGS->autothumb || !in_array($extension,$ok_types) || !GIF_SUPPORT || !GD_SUPPORT)
{
?>
<tr>
<td align="left" class="tdHeight"><b><?php echo $msg_addimg8; ?></b>:</td>
<td align="left" class="tdHeight"><input type="hidden" name="upload" value="1">
<input type="file" size="35" name="thumb[]" class="filebox"> (<?php echo $msg_addimg4; ?>)</td>
</tr>
<?php
}
?>
<tr>
<td align="left" class="tdHeight"><b><?php echo $msg_addimg9; ?></b>:</td>
<td align="left" class="tdHeight">
<select name="cat[]">
<?php
//Show cats if any exist
if (count($cat_array)>0) {
foreach ($cat_array AS $cat_data){
echo str_replace("{url}","",$cat_data);
}
}
?>
</select>
</td>
</tr>
<tr>
<td align="left" class="tdHeight"><b><?php echo $msg_addimg11; ?></b>:<br><br><i>(<?php echo $msg_addimg14; ?>)</i></td>
<td align="left" class="tdHeight"><textarea name="comments[]" style="width:90%" rows="5" cols="20"></textarea></td>
</tr>
<tr>
<td align="left" class="tdHeight"><b><?php echo $msg_cats20; ?></b>:</td>
<td align="left" class="tdHeight"><input type="text" name="keywords[]" maxlength="200" class="formbox"> <i>(<?php echo $msg_addimg14; ?>)</i> <?php echo toolTip($msg_javascript2,$msg_javascript49); ?></td>
</tr>
<tr>
<td align="left" class="tdHeight"><b><?php echo $msg_cats21; ?></b>:</td>
<td align="left" class="tdHeight"><input type="text" name="description[]" maxlength="200" class="formbox"> <i>(<?php echo $msg_addimg14; ?>)</i> <?php echo toolTip($msg_javascript2,$msg_javascript50); ?></td>
</tr>
<?php
// Is cart enabled..show buy options..
if ($SETTINGS->cart)
{
?>
<tr>
<td align="left" class="tdHeight"><b><?php echo $msg_addimg6; ?></b>:</td>
<td align="left" class="tdHeight"><?php echo $msg_script5; ?> <input type="radio" name="sale_item_<?php echo $saleNo; ?>" value="1"> <?php echo $msg_script6; ?> <input type="radio" name="sale_item_<?php echo $saleNo; ?>" value="0" checked></td>
</tr>
<tr>
<td align="left" class="tdHeight"><b><?php echo $msg_addimg15; ?></b>:<br><br><i><?php echo $msg_addimg23; ?></i><br><br>[<a href="index.php?cmd=add_images&salehelp=1" rel="gb_page_center[450, 400]" title="<?php echo $msg_addimg24; ?>"><b>?</b></a>]</td>
<td align="left" class="tdHeight"><textarea name="item_details[]" style="width:90%" rows="5" cols="20"></textarea></td>
</tr>
<?php
}
?>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<?php
}
}
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="background-color:#1EB5DD;border:1px solid #063052">
<tr>
<td align="center" style="padding:10px"><input class="formbutton" type="submit" value="<?php echo $msg_addimg12; ?>" title="<?php echo $msg_addimg12; ?>"></td>
</tr>
</table>
<?php
}
else
{
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="background-color:#1EB5DD;border:1px solid #063052">
<tr>
<td align="center" colspan="2" style="padding:10px;"><?php echo $msg_addimg5; ?></td>
</tr>
</table>
<?php
}
?>
</form>
</div>