Files
2017-03-02 20:30:40 -06:00

183 lines
6.4 KiB
PHP

<?php
/*
+--------------------------------------------------------------------------
| CubeCart 4
| ========================================
| CubeCart is a registered trade mark of Devellion Limited
| Copyright Devellion Limited 2006. All rights reserved.
| Devellion Limited,
| 5 Bridge Street,
| Bishops Stortford,
| HERTFORDSHIRE.
| CM23 2JU
| UNITED KINGDOM
| http://www.devellion.com
| UK Private Limited Company No. 5323904
| ========================================
| Web: http://www.cubecart.com
| Email: info (at) cubecart (dot) com
| License Type: CubeCart is NOT Open Source Software and Limitations Apply
| Licence Info: http://www.cubecart.com/site/faq/license.php
+--------------------------------------------------------------------------
| extraImgs.inc.php
| ========================================
| Add/Edit/Delete Unlimited Extra Product Images
+--------------------------------------------------------------------------
*/
if(!defined('CC_INI_SET')){ die("Access Denied"); }
$skipFooter = 1;
$lang = getLang("admin".CC_DS."admin_products.inc.php");
// add
if(isset($_GET['add']) && !empty($_GET['add'])) {
$record['img'] = $db->mySQLSafe(urldecode($_GET['add']));
$record['productId'] = $db->mySQLSafe($_GET['productId']);
$insert = $db->insert($glob['dbprefix']."CubeCart_img_idx", $record);
unset($record);
if($insert == TRUE){
$msg = "<p class='infoText'>".$lang['admin']['products_img_added_to_prod']."</p>";
} else {
$msg = "<p class='warnText'>".$lang['admin']['products_img_not_added_to_prod']."</p>";
}
$count['noImages'] = "noImages + 1";
$db->update($glob['dbprefix']."CubeCart_inventory", $count, "productId = ".$db->mySQLSafe($_GET['productId']));
} elseif(isset($_GET['remove']) && !empty($_GET['remove'])) {
$where = "img=".$db->mySQLSafe(urldecode($_GET['remove']))." AND productId=".$db->mySQLSafe($_GET["productId"]);
$delete = $db->delete($glob['dbprefix']."CubeCart_img_idx", $where);
if($delete == TRUE){
$msg = "<p class='infoText'>".$lang['admin']['products_img_removed']."</p>";
} else {
$msg = "<p class='warnText'>".$lang['admin']['products_img_not_removed']."</p>";
}
$count['noImages'] = "noImages - 1";
$db->update($glob['dbprefix']."CubeCart_inventory", $count, "productId = ".$db->mySQLSafe($_GET['productId']));
}
$query = "SELECT img FROM ".$glob['dbprefix']."CubeCart_img_idx WHERE productId=".$db->mySQLsafe($_GET['productId']);
$imgArray = $db->select($query);
if($imgArray == TRUE){
for ($i=0; $i<count($imgArray); $i++){
$key = $imgArray[$i]['img'];
$imgIndex[$key] = 1;
}
}
$currentPage = $_SERVER['PHP_SELF']."?productId=".$_GET['productId']."&amp;img=".$_GET['img'];
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title><?php echo $lang['admin']['products_image_management'];?></title>
<link rel="stylesheet" type="text/css" href="<?php echo $glob['adminFolder']; ?>/styles/style.css">
</head>
<body>
<p class="pageTitle"><?php echo $lang['admin']['products_manage_images'];?></p>
<?php
$page = (isset($_GET['page']) && $_GET['page']>0)? $_GET['page'] : '';
$thumbsPerPage = 20;
$exclude = array('add', 'remove');
$dirArray = walkDir(CC_ROOT_DIR .CC_DS."images".CC_DS."uploads", true, $thumbsPerPage, $page, false, $int = 0);
$pagination = paginate($dirArray['max'], $thumbsPerPage, $page, 'page', $class="txtLink", 10,$exclude);
if (isset($msg)) echo msg($msg);
echo '<p class="copyText">'.$pagination.'</p>';
?>
<table border="0" width="100%" cellspacing="1" cellpadding="3" class="mainTable">
<tr>
<td class="tdTitle"><?php echo $lang['admin']['products_image'];?></td>
<td class="tdTitle">&nbsp;</td>
<td align="center" class="tdTitle"><?php echo $lang['admin']['products_action'];?></td>
</tr>
<?php
if(is_array($dirArray)){
foreach($dirArray as $fileRoot) {
// get root rel link
$imageRootRel = imgPath($fileRoot,$thumb=0,$path="rel");
// win switch path
$imageRootRel = str_replace("\\","/",$fileRoot);
$imageSize = @getimagesize($fileRoot);
$image = imgPath($fileRoot,$thumb=0,$path="");
$thumbRoot = imgPath($fileRoot,$thumb=1,$path="root");
$thumbImg = imgPath($fileRoot,$thumb=1,$path="rel");
if (checkImgExt(strtolower($fileRoot)) && !eregi("thumb_",$fileRoot) && $image!==$_GET['img']){
$i++;
$cellColor = cellColor($i);
?>
<tr>
<td class="<?php echo $cellColor; ?>">
<?php
if(file_exists($thumbRoot))
{
?>
<img src="<?php echo $thumbImg; ?>" alt="" title="" />
<br />
<?php
}
?>
<a href="javascript:;" onClick="openPopUp('<?php echo $glob['adminFile']; ?>?_g=filemanager/preview&amp;file=<?php echo $fileRoot."&amp;x=".$size[0]."&amp;y=".$size[1]; ?>','filemanager',<?php echo $size[0]+12; ?>,<?php echo $size[1]+12; ?>)" class="txtDir"><?php echo $image; ?></a>
</td>
<td align="center" class="<?php echo $cellColor; ?>"><span class="copyText"><?php echo format_size(filesize($fileRoot)); ?></span></td>
<td align="center" class="<?php echo $cellColor; ?>">
<?php
if(isset($imgIndex[$image])){
?>
<a href="<?php echo $glob['adminFile']; ?>?_g=products/extraImgs&amp;productId=<?php echo $_GET['productId']?>&amp;remove=<?php echo urlencode($image); ?>&amp;img=<?php echo $_GET['img'];?>&amp;page=<?php echo $_GET['page'];?>" class="txtLink"><?php echo $lang['admin_common']['remove'];?></a>
<?php
} else {
?>
<a href="<?php echo $glob['adminFile']; ?>?_g=products/extraImgs&amp;productId=<?php echo $_GET['productId']?>&amp;add=<?php echo urlencode($image); ?>&amp;img=<?php echo $_GET['img'];?>&amp;page=<?php echo $_GET['page'];?>" class="txtLink"><?php echo $lang['admin_common']['add'];?></a>
<?php
}
?>
</td>
</tr>
<?php
}
}
}
if(!isset($i)){
?>
<tr>
<td colspan="3" class="copyText"><?php echo $lang['admin']['products_no_images_avail']; ?> <a href="<?php echo $GLOBALS['rootRel'].$glob['adminFolder']; ?>/includes/rte/editor/filemanager/browser/default/browser.php?Type=uploads&Connector=connectors/php/connector.php&amp;nullLink=1" class="txtLink"><?php echo $lang['admin']['products_upload_new_images']; ?></a></td>
</tr>
<?php
}
?>
</table>
<p class="copyText"><?php echo $pagination; ?>
<p align="center"><a href="javascript:window.close();" class="txtLink"><?php echo $lang['admin']['products_close_window'];?></a></p>
</body>
</html>