<?php	
define('IN_OUN', true);
include_once( "includes/command.php");
include_once(ROOT_PATH . 'class/cls_image.php');
$image = new cls_image($_CFG['bgcolor']);
include_once(ROOT_PATH.'includes/ckeditor/ckeditor.php');   
if($Aconf['priveMessage'] != '')
{
   echo showMessage($Aconf['priveMessage']);
   exit;
}

if(!$_SESSION[$un_apraid])
{
   $strMessage = '此账号没有绑定经销商，不能操作！请通过管理员设置.<br/><br/><a href="adminuser.php">用户权限->基本资料编辑 ->账号属于经销商</a>';
   echo  showMessage($strMessage);
   exit;
}

if($_POST['act'] == 'insert' || $_POST['act'] == 'update' )
{
	$is_insert   = $_POST['act'] == 'insert';
	$myuser_id   = $_SESSION[$un_auser_id];
	$up_date = local_strtotime($_POST[up_date]);
    if(trim($_POST[name]) == '' )
	{
		$strMessage = '标题及内容不能为空';
	}
	else
	{
 	    /* 处理主图 */
		$shop_thumb = $_POST['old_shop_thumb'];
		$min_thumb = $_POST['old_min_thumb'];
	    if($_FILES["shop_thumb"]["size"] > 0 )
	    {
		    /* 判断图像类型 */
            if (!$image->check_img_type($_FILES['shop_thumb']['type']))
            {
                $strMessage =  '图片类型错误,只支持 .jpg,.gif,.png格式.\n';
            }
		    else
		    {
			    if($_FILES["shop_thumb"]["size"] > settype($_POST['MAX_FILE_SIZE'], "integer"))
			    {
				    $strMessage =  '文件太大，不能上传：最大为2M.\n';
			    }
			    else
			    {		
                    /* 生成缩略图 */
                    $shop_thumb = $image->make_thumb($_FILES["shop_thumb"]['tmp_name'], 208,  208);

                    /* 像册 */
					$thumb_url = $image->make_thumb($_FILES["shop_thumb"]['tmp_name'], 80,  80);
					$min_thumb = $thumb_url;
				    /* 原图 */
                    $filename = $image->upload_image($_FILES["shop_thumb"]);
			     }
		     }		  
	     } 
	     /* 像册图片处理 star */
         /* 检查图片：如果有错误，检查尺寸是否超过最大值；否则，检查文件类型 */
         if (isset($_FILES['img_url']['error'][0])) // php 4.2 版本才支持 error
         {
             // 最大上传文件大小
             $php_maxsize = ini_get('upload_max_filesize');
             $htm_maxsize = '2M';
             // 相册图片
             foreach ($_FILES['img_url']['error'] AS $key => $value)
             {				
                 if ($value == 0)
                {		
                    if (!$image->check_img_type($_FILES['img_url']['type'][$key]))
                    {
                       $strMessage = '文件类型错误:'.$key;
					   break;
                    }
                 }
                 elseif ($value == 1)
                {
                    $strMessage = '文件太大:'.$key.' '.$php_maxsize;
				    break;
                }
                elseif ($_FILES['img_url']['error'] == 2)
               {
                   $strMessage = '文件太大:'.$key.' '. $htm_maxsize;
			       break;
               }
             }
	      }
          /* 4。1版本 */
          else
          {
              // 相册图片
		      while( @list( $key, $value ) = @each( $_FILES['img_url']['tmp_name']) )
              {			
                  if ($value != 'none')
                  {				
                      if (!$image->check_img_type($_FILES['img_url']['type'][$key]))
                      {
                          $strMessage = '文件无效:'. $key + 1;
					      break;
                       }
                    }
                }
           }
	      /* 像册图片处理 end */

      //数据添加
	  $myuser_id   = $_SESSION[$un_auser_id];
	  $shop_sn = ($_POST[shop_sn] == '')?'un'.$_SESSION[$un_domain_id].date("ymdHms"):$_POST[shop_sn];
	  if($is_insert)
	  {
	    /* 入库 */
		
		$db_table = $pre.'pravail_producttxt';
		$sql = "INSERT INTO " . $db_table . " ( `prapcid` , `praid` , `pacid`,`prbid`,`user_id`,`name`,`shop_sn`,`shop_price`,`up_date` ,`shop_number`,`min_thumb`,`shop_thumb`, `top` , `dateadd` , `states` , `domain_id` )" .
                 "VALUES ('$_POST[prapcid]',$_SESSION[$un_apraid],'$_POST[pacid]', '$_POST[prbid]','$myuser_id', '$_POST[name]', '$shop_sn', '$_POST[shop_price]','".$up_date."', '$_POST[shop_number]', '$min_thumb','$shop_thumb', '$_POST[top]',  '".gmtime()."', '0','$_SESSION[$un_domain_id]')"; 
        $oPub->query($sql);
        /* 编号 */
        $prid = $is_insert ? $oPub->insert_id() : $_POST['prid'];
        /* 详细记录 */
        $db_table = $pre.'pravail_product';
		$sql = "INSERT INTO " . $db_table . " ( `prid` ,  `descs` ,`file_exp`,`dateadd` , `domain_id`  )" .
                 "VALUES ($prid,'$_POST[descs]', '$_POST[file_exp]','".gmtime()."', '$_SESSION[$un_domain_id]')"; 
        $oPub->query($sql);
		/* 属性赋值 */
        $db_table = $pre.'pravail_prattrival';
		while( @list( $k, $v) = @each($_POST['attr_name']) )
        {
			if($v){
		       $sql = "INSERT INTO " . $db_table . " ( `paid` , `prid`,`pavals` ,`domain_id`)  VALUES ('$k','$prid','$v',$_SESSION[$un_domain_id])"; 
               $oPub->query($sql);
			}
		}

		/* 相册 */
		if($filename && $thumb_url)
		{
		     $db_table = $pre.'pravail_product_file';
		     $sql = "INSERT INTO " . $db_table . " ( `prid` ,  `filename` , `thumb_url`,`domain_id` )" .
                    "VALUES ($prid,'$filename', '$thumb_url',$_SESSION[$un_domain_id])"; 
             $oPub->query($sql);
		 }

		$strMessage .= '添加成功!';
		$_REQUEST[prid] = $prid;$_REQUEST['action'] = 'edit';

	  }
      else if($_POST['act'] == 'update' && $_POST['prid'] > 0)
	  {
		$db_table = $pre.'pravail_producttxt';
		$prid = $_POST['prid'] + 0;
        $sql = "UPDATE " . $db_table . " SET 
               `prapcid`='$_POST[prapcid]' , 
			   `pacid`='$_POST[pacid]' , 
			   `prbid`='$_POST[prbid]' , 
               `name`='$_POST[name]' ,
			   `shop_sn`='$shop_sn' ,
			   `shop_price`='$_POST[shop_price]' ,
               `up_date`='".$up_date."' ,
			   `shop_number`='$_POST[shop_number]', 
			   `min_thumb` = '$min_thumb' ,
			   `shop_thumb`='$shop_thumb' ,
               `top`='$_POST[top]' 
		        WHERE `prid` =".$prid." and `domain_id`=".$_SESSION[$un_domain_id];
        $oPub->query($sql); 
		$db_table = $pre.'pravail_product';
        $sql = "UPDATE " . $db_table . " SET 
               `descs`= '$_POST[descs]', 
			   `file_exp`= '$_POST[file_exp]'  
		        WHERE `prid` =".$prid." and `domain_id`=".$_SESSION[$un_domain_id];
        $oPub->query($sql);
		/* 属性赋值 */
        $db_table = $pre.'pravail_prattrival';
        $sql = "delete from ".$db_table." WHERE prid  = '".$prid."'";
        $oPub->query($sql);

		while( @list( $k, $v) = @each($_POST['attr_name']) )
        {
			if($v)
			{
		            $sql = "INSERT INTO " . $db_table . " ( `paid` , `prid`,`pavals` ,`domain_id`)  VALUES ('$k','$prid','$v',$_SESSION[$un_domain_id])"; 
                    $oPub->query($sql);
			}
		}

		/* 相册 */
		if($filename && $thumb_url)
		{
		     $db_table = $pre.'pravail_product_file';
		     $sql = "INSERT INTO " . $db_table . " ( `prid` ,  `filename` , `thumb_url` ,`domain_id` )" .
                    "VALUES ($prid,'$filename', '$thumb_url',$_SESSION[$un_domain_id])"; 
             $oPub->query($sql);
		 }
		/* 编辑图片描述 old_img_desc */
		if (isset($_POST['old_img_desc']))
        {
			foreach ($_POST['old_img_desc'] AS $key => $val)
           {
				$db_table = $pre.'pravail_product_file';
				$sql = "UPDATE " . $db_table . " SET `descs` = '$val' WHERE `fileid` =".$key;
                $oPub->query($sql);              
		   }
		}
        $strMessage .= '修改成功！';
	  }

	  /* 处理相册图片 */
      handle_gallery_imagepro($prid, $_FILES['img_url'], $_POST['namedesc']);
    }//if(trim($_POST[name]) == '')
}
/* 编辑修改结束 */


if($_REQUEST['action'] == 'edit' && $_REQUEST[prid])
{ 
	$prid = $_REQUEST[prid];
	$sql = "SELECT a.*,b.descs,b.file_exp    
	        FROM ".$pre."pravail_producttxt as a,".$pre."pravail_product as b 
			where a.prid = b.prid 
			AND a.prid = '$prid'
			AND a.domain_id=$_SESSION[$un_domain_id]";
    $work = $oPub->selectrow($sql);

	/* 产品属性 start */
    if($work[pacid] > 0 )
	{
		$Strprattvalue = '<div style="margin-left: 30px">';
        $db_table = $pre."prattri";
        $sql = "SELECT paid,pacid,attr_name,attr_input_type,attr_values  FROM ".$db_table." 
                WHERE `pacid` = $work[pacid] 
			    ORDER BY sort_order,paid ASC";
        $row = $oPub->select($sql);
        while( @list( $k, $v) = @each( $row) ) 
	    {
		    /* 取对应值 */
		    if($work[prid])
		    {
                $db_table = $pre."pravail_prattrival";
                $sql = "SELECT pavals  FROM ".$db_table." 
                       WHERE `paid` = $v[paid] 
			           AND prid  = $work[prid]
			           limit 1";
			    $rowpavals = $oPub->selectrow($sql);
		    }
		    else
		    {
               $rowpavals[pavals] = '';
		    }

		   $Strprattvalue .= '<span style="margin: 5px;">'.$v[attr_name].':</span>';
		   $Strprattvalue .= '<span>';
		   if(!$v[attr_input_type])
		   {
		       $Strprattvalue .= '<INPUT TYPE="text" NAME="attr_name['.$v[paid].']" size="20" value="'.$rowpavals[pavals].'"/>'; 
		   }
		   else
		   {
			    $Strprattvalue .= '<SELECT NAME="attr_name['.$v[paid].']">';
			    $attr_values = str_replace("\n", ", ",$v["attr_values"]);
			    $Aattr_values = explode(", ",$attr_values);
                while( @list( $key, $val) = @each( $Aattr_values) ) 
	           {
				    $selected = ($rowpavals[pavals] == $val)?'SELECTED':'';
			        $Strprattvalue .= '<OPTION VALUE="'.$val.'" "$selected">'.$val.'</OPTION>';

			   }
			  $Strprattvalue .= '</SELECT>';
		   }
		   $Strprattvalue .= '</span><br/>';
        }
	}
    /* 产品属性 end */

	/* 像册列表 */
	$db_table = $pre.'pravail_product_file';
    $sql = "SELECT * FROM " . $db_table . " WHERE prid = '$prid'";
    $img_list = $oPub->select($sql);
}

/* 找到所有的产品分类到select start*/
$db_table = $pre."pravail_productcat"; 
$sql = "SELECT * FROM ".$db_table." where praid = '".$_SESSION[$un_apraid]."' AND domain_id=".$_SESSION[$un_domain_id]." ORDER BY prapcid ASC";
$AnormAll = $oPub->select($sql);

$Stropt = '<SELECT NAME="prapcid">';
$n = 0;
while( @list( $key, $value ) = @each( $AnormAll) ) {
	   $n ++;
       $selected = ($_REQUEST['prapcid'] == $value["prapcid"])? 'SELECTED':'';
       $Stropt .= '<OPTION VALUE="'.$value["prapcid"].'" '.$selected.' >'.$value["name"].'</OPTION>';
   
}
$Stropt .= '</SELECT>';
/* 找到所有的分类到select end*/

/* 找到所有的产品属性 select start*/
$db_table = $pre."prattcat"; 
$sql = "SELECT pacid,paname FROM ".$db_table." where enabled = 1  ORDER BY pacid ASC";
$AnormAll = $oPub->select($sql);

$Strprattcatopt = '<SELECT NAME="pacid" id="pacid" onchange="return check_prattri()">';
$Strprattcatopt .= '<OPTION VALUE="0" >选择产品属性</OPTION>';
$n = 0;
while( @list( $key, $value ) = @each( $AnormAll) ) {
	   $n ++;
       $selected = ($work[pacid] == $value["pacid"])? 'SELECTED':'';
       $Strprattcatopt .= '<OPTION VALUE="'.$value["pacid"].'" '.$selected.' >'.$value["paname"].'</OPTION>';
  
}
$Strprattcatopt .= '</SELECT>';
/* 找到所有的产品属性 select end*/

/* 找到所有的产品品牌 select start*/
$db_table = $pre."probrand"; 
$sql = "SELECT prbid,brand_name FROM ".$db_table." where is_show = 1 AND domain_id=".$_SESSION[$un_domain_id]." ORDER BY prbid ASC";
$AnormAll = $oPub->select($sql); 
$Strprobrandopt = '<SELECT NAME="prbid">';
$Strprobrandopt .= '<OPTION VALUE="0" >选择产品品牌</OPTION>';
$n = 0;
if($AnormAll)
foreach($AnormAll as $key => $value)
{
	   $n ++;
       $selected = ($work['prbid'] == $value["prbid"])? 'SELECTED':'';
       $Strprobrandopt .= '<OPTION VALUE="'.$value["prbid"].'" '.$selected.' >'.$value["brand_name"].'</OPTION>';
  
}
$Strprobrandopt .= '</SELECT>';
/* 找到所有的产品品牌 select end*/
?>
<?php
include_once( "header.php"); 
if ($strMessage != '')
{
 echo  '<SCRIPT language="javascript"> alert( "'.$strMessage.'");</script>';
}
?>
  <table width="800" border="0" cellspacing="0" cellpadding="0" class="button">
    <tr>
      <td align="middle">
       <span style="float: left"><a href="prav_productsend.php"> [经销商添加新产品]</a> </span>
	   <span style="float: right"> <a href="prav_productlist.php"> [经销商产品列表]</a></span>
     </td>
    </tr>
  </table>
<form action="" method="post" name="theForm" enctype="multipart/form-data" style="margin:0" />
<TABLE width="800" border="0"  cellspacing="0" cellpadding="0">
 
  <TR class=bg1>
    <TD align=left>

	      <input type="hidden" name="MAX_FILE_SIZE" value="2097152" /> 
		 <span style="color: #FF0000">*</span> 
         <b> 名 称 ： </b>
		 <input type="text" size="16" name="name" value="<?php echo ($work["prid"] > 0)?$work["name"]:'';?>" size="20"/>
		 		 
		 <b>编号：</b>
		 <input type="text" name="shop_sn" value="<?php echo ($work["prid"] > 0)?$work["shop_sn"]:'';?>" size="20"/>
		 <b>价格：</b>
		 <input type="text" name="shop_price" value="<?php echo ($work["prid"] > 0)?$work["shop_price"]:'0.00';?>" size="10"/>
		  <br/>
		 <b>上市日期：</b>
		 <input type="text" name="up_date" value="<?php echo ($work["prid"] > 0)?date("Y-m-d",$work["up_date"]):date("Y-m-d");?>" size="10"/>
        
         <b>分类选择：</b>
		 <?php echo $Stropt;?>
         <b>品牌选择：</b>
		 <?php echo $Strprobrandopt;?>

		 <?php
		 $Strtopopt = '<b>置顶：</b>';
         $Strtopopt .= '<SELECT NAME="top">';
         $selected0 = ($work[top]==0)?'selected':'';
		 $selected1 = ($work[top]==1)?'selected':'';
         $Strtopopt .= '<OPTION VALUE="0" '.$selected0.' >否</OPTION>';
		 $Strtopopt .= '<OPTION VALUE="1" '.$selected1.' >是</OPTION>';
         $Strtopopt .= '</SELECT>';
		 echo $Strcolorsopt.$Strtopopt;
		 ?>	
		 <div style="clear:left"></div>
		 <b>产品缩图：</b>		 
		 <input type="file" name="shop_thumb"  size="20"/>
		 <span id="prod_thumb_show">
         <?php 
		 if($work["shop_thumb"]) {
			 $tmp = '<A HREF="../'.$work["shop_thumb"].'" target="_blank">';
			 $tmp .= '<IMG SRC="images/icon_view.gif" WIDTH="16" HEIGHT="16" BORDER="0" ALT="显示缩图"></A> ';
			 $tmp .= '<a href="javascript:;" onclick="if (confirm(\'删除\')) drop_prodtxtImg(\''.$work["prid"].'\',\''.$work["shop_thumb"].'\')">';
			 $tmp .= '<IMG SRC="images/b_drop.png" WIDTH="16" HEIGHT="16" BORDER="0" ALT="删除缩图"></A> ';
		     $tmp .= '<input type="hidden" name="old_shop_thumb" value="'.$work["shop_thumb"].'" />';
			 $tmp .= '<input type="hidden" name="old_min_thumb" value="'.$work["min_thumb"].'" />';
		 } else {
             $tmp = '<input type="hidden" name="old_shop_thumb" value="" />';
			 $tmp .= '<input type="hidden" name="old_min_thumb" value="" />';
		 }
		 echo $tmp;
		 ?>
		 </span>
	</TD> 
  </TR>
  <TR class=bg1>
    <TD align=left>
	<b>产品描述：</b>
	<?php  echo create_html_ck('descs',$work["descs"]); ?>  
	</TD> 
  </TR>
</TABLE>
<!-- 附件 start -->
<DIV id=tabbar-div></DIV><!-- tab body -->
<TABLE id=gallery-table width="800" align="left">
 <tr>
   <td>
	相册：(<U>1.点“加号”可以批量上传多张图片；2.点提交按钮提交图片；3.单击相册列表中的缩图，可把原图添加到编辑器中</U>) 
	<div id="delimg_show" style="margin: 0">
	<?php
	while( @list( $k, $v ) = @each( $img_list) )
	{
	?>
		  <div id="gallery_<?php echo $v['fileid'];?>" style="float:left; text-align:center; border: 1px solid #DADADA; margin: 4px; padding:2px;">
			<a href="javascript:;" onclick="if (confirm('删除')) dropImg('<?php echo $v['fileid'];?>','<?php echo $v['prid'];?>')" title="删除">[-]</a>
			<a href="../<?php echo $v['filename'];?>" target="_blank" title="查看原信息:<?php echo $v['descs'];?>">[>]</a>  
			<br />                
			<?php if($v['thumb_url'] != '') { ?>
				 <img src="../<?php  echo $v['filename'];?>" width="120" height="90"  border="0" title="插入编辑器" onclick="InsertHTML('insert<?php echo  $v['fileid'];?>');" id="insert<?php echo   $v['fileid'];?>" />
			<?php } else {?>
				 <div style="width:120;height:90"><br/><br/><a href="../<?php  echo $v['filename'];?>" target="_blank">查阅>></a></div>
			<?php  }?>
				<br />
			<input type="text" value="<?php echo $v['descs'];?>" size="15" name="old_img_desc[<?php echo $v['fileid'];?>]" />
		  </div>
	<?php
	}
	?>
	</div>
    </TD> 
  </TR> 
  <TR>
    <TD>
	<A onclick=addImg(this) href="javascript:;">[+]</A> 
	描述:<INPUT TYPE="text" NAME=namedesc[] value="" size="30"/>
	地址:<INPUT type=file name=img_url[]> 
	</TD>
  </TR>
</TABLE>
  <!-- 附件 end -->
<div style="clear:all"></div>
<TABLE width="800" border=0>
  <TR class=even>
    <TD align=left>
	  <b>产品属性：</b> 
      <?php echo $Strprattcatopt;?>
      <div id="prattri">
	  <?php echo $Strprattvalue;?>
	  </div>
    </TD> 
  </TR>
   <TR class=bg1>
    <TD align=left>
       <input type="submit" value="<?php echo ($work["prid"] > 0)?'修改产品':'提交新产品';?>" style="background-color: #FFCC66;margin-left: 100px"/>
	   <input type="hidden" name="prid" value="<?php echo ($work["prid"] > 0)?$work["prid"]:0;?>" id="prid" />
       <input type="hidden" name="act" value="<?php echo ($work["prid"] > 0)?'update':'insert';?>" /> 
    </TD> 
  </TR>
 </table>

</form>
<SCRIPT src="js/tab.js" type="text/javascript"></SCRIPT>
<SCRIPT src="js/utils.js" type="text/javascript"></SCRIPT>	
<SCRIPT src="../js/ajax.js" type="text/javascript"></SCRIPT>
 
<SCRIPT language=JavaScript>
  function addImg(obj)
  {
      var src  = obj.parentNode.parentNode;
      var idx  = rowindex(src);
      var tbl  = document.getElementById('gallery-table');
      var row  = tbl.insertRow(idx + 1);
      var cell = row.insertCell(-1);
      cell.innerHTML = src.cells[0].innerHTML.replace(/(.*)(addImg)(.*)(\[)(\+)/i, "$1removeImg$3$4-");
  }

  /**
   * ~{I>3}M<F,IO4+~}
   */
  function removeImg(obj)
  {
      var row = rowindex(obj.parentNode.parentNode);
      var tbl = document.getElementById('gallery-table');

      tbl.deleteRow(row);
  }

  /**
   * ~{I>3}M<F,~}
   */
  function dropImg(fileid,prid)
  {
    obj = "delimg_show";
	var strTemp = "ajax_prav_product_delimg.php?fileid=" + fileid + "&prid=" + prid + "&op=delimg&action=edit";
	//alert(strTemp);
	//document.getElementById('gallery_' + fileid).style.display = 'none';
	send_request(strTemp);	
  }
  function drop_prodtxtImg(prid,prod_thumb_file)
  {
    obj = "prod_thumb_show";
	var strTemp = "ajax_prav_product_delimg.php?prid=" + prid + "&prod_thumb_file=" + prod_thumb_file; 
	send_request(strTemp);	
  }
  function check_prattri()
    {
     obj = "prattri";
	 var pacid = document.getElementById("pacid").value;
	 var prid = document.getElementById("prid").value;
	 
	 var strTemp = "ajax_prav_check_prattri.php?pacid=" + pacid + "&prid=" + prid; 
	 send_request(strTemp);
  }
function InsertHTML(a)
{
	var oEditor = CKEDITOR.instances.descs; 
	var value = '<img src="' + document.images(a).src + '"/>';  
	if ( oEditor.mode == 'wysiwyg' ) { 
		oEditor.insertHtml( value );
	}
	else
		alert( 'You must be on WYSIWYG mode!' );
} 
</SCRIPT>
<?php

/**
 * 保存某商品的相册图片
 * @param   int     $workid
 * @param   array   $image_files
 * @param   array   $image_descs
 * @return  void
 */
function handle_gallery_imagepro($prid, $image_files, $image_descs)
{
	global $image,$oPub,$pre,$_SESSION,$un_domain_id;
	$imgType = array(1 => 'image/gif', 2 => 'image/jpeg', 3 => 'image/png',4 => 'image/pjpeg');
	while( @list( $key, $img_desc ) = @each( $image_descs) )
    {
        /* 是否成功上传 */
        $flag = false;
        if (isset($image_files['error']))
        {
            if ($image_files['error'][$key] == 0)
            {
                $flag = true;
            }
        }
        else
        {
            if ($image_files['tmp_name'][$key] != 'none')
            {
                $flag = true;
            }
        }

        if ($flag)
        {
            // 生成缩略图
			//if( in_array($image_files['type'][$key],$imgType) )
			if($image->check_img_type($image_files['type'][$key]))
			{
				
               $thumb_url = $image->make_thumb($image_files['tmp_name'][$key], 80,  80);
			}
            $thumb_url = is_string($thumb_url) ? $thumb_url : '';

            $upload = array(
                'name' => $image_files['name'][$key],
                'type' => $image_files['type'][$key],
                'tmp_name' => $image_files['tmp_name'][$key],
                'size' => $image_files['size'][$key],
            );
            if (isset($image_files['error']))
            {
                $upload['error'] = $image_files['error'][$key];
            }
            $img_original = $image->upload_image($upload);
            $img_url = $img_original;

            $db_table = $pre.'pravail_product_file';
			if(empty($img_desc)){
				$A = explode(".",$image_files['name'][$key]);
				$img_desc = $A[0];
			}
            $sql = "INSERT INTO " . $db_table. " (prid, filename,thumb_url,descs,domain_id) " .
                    "VALUES ('$prid', '$img_url', '$thumb_url','$img_desc',$_SESSION[$un_domain_id])";
            $oPub->query($sql);

        }
    }
}

?>
<?php
include_once( "footer.php");
?>

