⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 listimg.php

📁 这个版本只是修正了一些BUG
💻 PHP
字号:
<?php
/**********************************************
    	listimg.php

	Version  : 1.2
	Author   : nnaqing
	Copyright: www.free-buy.net
	Writed   : 2004/04/05
	Modified : 2004/04/14
************************************************/
require "./include/base.php";
require "./include/buy.php";

if($method == 'del')
{
	if(unlink($img))
	{
		showmessage('delsuccess',"listimg.php?action=$action&type=$type&productid=$productid");
	}
	else
	{
		showmessage('file_del_fail');
	}	
}

if($action=='new')
{
	$nav .= SEPARATER."<a href='editproduct.php?action=$action'>".$language['addproduct']."</a>";
	$nav .= SEPARATER.$language['product_img_select'];
}
elseif($action=='edit')
{
	$nav .= SEPARATER."<a href='editproduct.php?action=$action&productid=$productid'>".$language['editproduct']."</a>";
	$nav .= SEPARATER.$language['product_img_select'];
}

$app = 16;
if($type=='listsmlimg')
{
	$prdimgdir = $shop_root.'./productimgs/smallimg';
	$prdimgurl='productimgs/smallimg/';
}
elseif($type=='listlgeimg')
{
	$prdimgdir = $shop_root.'./productimgs/largeimg';
	$prdimgurl='productimgs/largeimg/';
}
if($productid)
{
	$query = $db->query("select smallimg,largeimg from $table_products where productid=$productid",1);
	if($product = $db->fetch_array($query))
	{
		if($type=='listsmlimg')
		{
			$productimg=$product[smallimg];
		}
		elseif($type=='listlgeimg')
		{
			$productimg=$product[largeimg];
		}
	}
}
if($selimgsubmit)
{
	if($prdimgnew == 'upload')
	{
		if($uploadfile != "" && $uploadfile != "none" ) 
		{ 
			$expfilename=random(4);
			$tofile =$prdimgdir."/".$expfilename."_$uploadfile_name";
			
			$filesize = GetImageSize($uploadfile);			 
			if(!$filesize[2])	showmessage("img_upload_err_type");
			if($type=='listsmlimg')
			{
				if(($filesize[0] > 101) ||($filesize[1] > 101))
					showmessage("img_upload_err_size");
			}
			if (!copy($uploadfile,$tofile)) showmessage("img_upload_err_file");
			unlink($uploadfile);
			$prdimgnew=$prdimgurl.$expfilename."_$uploadfile_name"; 
			unset($expfilename);
		} 
		else 
		{ 
			showmessage("img_upload_err_file");
		}
	}
	if($action=='new')
	{
		showmessage('Loading....','editproduct.php?action=new&smallimg='.$prdimgnew);
	}
	elseif($action=='edit')
	{
		$filepath .=$shop_root.$productimg;
		if (file_exists($filepath))
				unlink($filepath);
		if($type=='listsmlimg')
		{
			$sqlstr="update $table_products set smallimg='$prdimgnew' where productid=$productid";
		}
		elseif($type=='listlgeimg')
		{
			$sqlstr="update $table_products set largeimg='$prdimgnew' where productid=$productid";
		}
		$query=$db->query($sqlstr,1);
		showmessage('product_img_select_success','editproduct.php?action=edit&productid='.$productid);
	}
}
/*

if(!$page) 
{
	$page = 1;
}

$imglist = "";
$num = 1;
if(is_dir($prdimgdir)) 
{
	$adir = dir($prdimgdir);
	while($entry = $adir->read()) 
	{
		if ($entry != '.' && $entry != '..') 
		{
			if (is_file("$prdimgdir/$entry")) 
			{
					$images[$num] = $entry;
					$num++;
			}
		}
	}
	$adir->close();
	$num--;
}
else 
{
	showmessage('prdimgdir_nonexistence');
	exit;
}

$start = ($page - 1) * $app;
$end = ($start + $app > $num) ? ($num - 1) : ($start + $app - 1);

$multipage = multi($num, $app, $page, "listimg.php?action=$action&type=$type&productid=$productid");
for($i = $start; $i <= $end; $i += 4) 
{
	$imglist .= "<tr>\n";
	for($j = 0; $j < 4; $j++) 
	{
		$thisbg = ($thisbg == ALTBG1) ? ALTBG2 : ALTBG2;
		$imglist .= "<td bgcolor=\"white\" width=\"25%\" align=\"center\">";
		if($images[$i + $j] && ($i + $j)) 
		{
			$filesize = GetImageSize($prdimgdir.'/'.$images[$i + $j]);
			$width=($filesize[0] > 80)?"width='80'":"";
			$height=($filesize[	1] > 80)?"height='80'":"";
			$imglist .= "<a href='".$prdimgurl.$images[$i + $j]."' target=_blank><img $width $height src='$prdimgurl".$images[$i + $j]."' border=0></a></td>\n";
		} 
		else 
		{
			$imglist .= "&nbsp;</td>\n";
		}
	}
	$imglist .= "</tr><tr>\n";
	for($j = 0; $j < 4; $j++) 
	{
		$imglist .= "<td bgcolor=\"".ALTBG1."\" width=\"25%\" align=\"center\">";
		if($images[$i + $j] && ($i + $j)) 
		{
			if(strpos($productimg, $images[$i + $j])) 
			{
				$checked = "checked";
			}
			else 
			{
				$checked = "";
			}
			$imagefile=$prdimgdir.'/'.$images[$i+$j];
			$imglist .= "<input type=\"radio\" value='".$prdimgurl.$images[$i + $j]."' name=\"prdimgnew\" $checked>&nbsp;".$images[$i + $j]." [<a href='listimg.php?action=$action&type=$type&productid=$productid&method=del&img=$imagefile' ><span class=hltext>delete</span></a></a>]\n";
		} 
		elseif($i + $j == 0) 
		{
			if(!$productimg) 
			{
				$checked = "checked";
			}
			$imglist .= "<input type=\"radio\" value=\"\" name=\"prdimgnew\" $checked><span class=\"bold\">&nbsp;".$language['product_img_notuse']."</span>\n";
		} 
		else 
		{
			$imglist .= "&nbsp;</td>\n";
		}
		$thisbg = ($thisbg == ALTBG1) ? ALTBG1 : ALTBG1;
	}
	$imglist .= "</tr><tr><td bgcolor=\"".ALTBG3."\" colspan=\"4\" height=\"1\"></td></tr>\n\n";
}
*/
include template('listimg');
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -