<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<?php  

require_once '../inc/logincheck.php';
require_once '../include/upfile.class.php';
require_once '../include/watermark.class.php';
require_once '../../config/config.inc.php';  
$fileSize = $_FILES['imgurl']['size'];
$googleweb_big_wate = $kuWebsiteImgBigWate;
$googleweb_thumb_wate = $kuWebsiteImgThumbWate;
$googleweb_wate_class = $kuWebsiteWateType;    
$googleweb_wate_img = '../'.$kuWebsiteImgWatePath;
$googleweb_watermark = $kuWebsiteCharacterWateMark;

if($phototype == 'product')
{
  $googleweb_img_x = $kuWebsiteImgThumbWithProduct;
  $googleweb_img_y = $kuWebsiteImgThumbHeightProduct;
}
else
{
  $googleweb_img_x = $kuWebsiteImgThumbWithImg;
  $googleweb_img_y = $kuWebsiteImgThumbHeightImg;
}

if('' != $kuWebsiteUploadImgMax && $fileSize > $kuWebsiteUploadImgMax*1024*1024)
{
  ?>
  <script type="text/javascript">
  alert(<?php echo '\''.$promptIncludeDirUploadImgSizeFormat.'\''; ?>);
  window.location.href='uploadfile.php?returnid=<?php echo $returnid;?>&create_samll=<?php echo $create_samll;?>&phototype=img';
  </script>
  <?php  
  exit;
}
  
$f = new upfile('','',$kuWebsiteUploadImgMax*1024*1024,'');
$img = new WaterMark();

if($_FILES['imgurl']['name']!='' && $returnid=="big")
{      
  $imgurl   = $f->upload('imgurl');
  $googleweb_big_img = $imgurl; 
  if($googleweb_big_wate==1)
  {
      if($googleweb_wate_class==2)
      {
          $img->googleweb_image_name = $googleweb_wate_img;//水印图片
          $img->googleweb_image_pos  = $googleweb_watermark;
      }
      else 
      {
          $img->googleweb_text = $kuWebsiteCharacterWateDescription;
          $img->googleweb_text_size = $kuWebsiteCharacterWateSize;
          $img->googleweb_text_color = $kuWebsiteCharacterWateColor;
          $img->googleweb_text_angle = $kuWebsiteCharacterWateAngle;
          $img->googleweb_text_pos   = $kuWebsiteCharacterWateMark;
          $img->googleweb_text_font = '../include/fonts/'.$kuWebsiteCharacterWateFont;
      }
      $img->src_image_name ="../".$imgurl;
      $img->save_file = $f->waterpath.$f->savename;
      $img->create();
    $imgurl ="../upload/".date('Ym')."/watermark/".$f->savename;
  }
  

  //缩图
 if($createsamll == 1 && $_FILES['imgurl']['name'] != '')
 {
      //CommTool::fileUnlink($imgurls);
      $googleweb_big_img="../".$googleweb_big_img;  
      $imgurls = $f->createthumb($googleweb_big_img,$googleweb_img_x,$googleweb_img_y);

      if($googleweb_thumb_wate==1)
      {
          if($googleweb_wate_class==2)
          {
              $img->googleweb_image_name = $googleweb_wate_img;//水印图片
              $img->googleweb_image_pos = $googleweb_watermark;
          }
          else
          {
            $img->googleweb_text = $kuWebsiteCharacterWateDescription;
            $img->googleweb_text_size = $kuWebsiteCharacterWateSize;
            $img->googleweb_text_color = $kuWebsiteCharacterWateColor;
            $img->googleweb_text_angle = $kuWebsiteCharacterWateAngle;
            $img->googleweb_text_pos   = $kuWebsiteCharacterWateMark;
            $img->googleweb_text_font = '../include/fonts/'.$kuWebsiteCharacterWateFont;
          }
          $img->save_file =$imgurls;
          $img->create($imgurls);
      }
      $imgurls_a=explode("../",$imgurls);
      $imgurls="../".$imgurls_a[2];
    }        
    echo "<SCRIPT language=javascript>\n";
    echo "parent.document.myform.imgurl.value='".$imgurl."';\n";
    echo "parent.document.myform.imgurlpre.value='".$imgurls."';\n";
    echo "parent.document.myform.imgurlprebrowse.src='".$imgurls."';\n";
    echo "alert('$promptIncludeDirUploadImgSuccess";
    echo round(($fileSize/1024), 2);
    echo "K');";
    echo "location.href='uploadphoto.php?returnid=";
    echo $returnid;
    echo "&createsamll=";
    echo $createsamll;
    echo "'; </script>";    
} 
//上传缩略图    
if($_FILES['imgurl']['name'] != '' && $returnid == "small") 
{  
  $f->savepath = $f->savepath.'/thumb/';
  $imgurls = $f->upload('imgurl');
  $imgurls_array=explode("/",$imgurls);
  $imgurls=$imgurls_array[0]."/".$imgurls_array[1]."/".$imgurls_array[2]."/thumb/".$imgurls_array[3];
  echo "<SCRIPT language=javascript>\n";
  echo "parent.document.myform.imgurlpre.value='".$imgurls."';\n";
  echo "alert('$promptIncludeDirUploadImgSuccess";
  echo round($fileSize/1024,2);
  echo "K');";
  echo "location.href='uploadphoto.php?returnid=";
  echo $returnid;
  echo "&createsamll=";
  echo $createsamll;
  echo "'; </script>";  
}
  
//上传LOGO图    
if($_FILES['imgurl']['name'] != '' && $returnid == "logo") 
{
  $f->savepath = $f->savepath;
  $imgurls = $f->upload('imgurl');
  $kuWebsiteLOGOPath = $imgurls;
  echo "<SCRIPT language=javascript>\n";
  echo "parent.document.myform.kuWebsiteLOGOPath.value='".$imgurls."';\n";
  echo "alert('$promptIncludeDirUploadImgSuccess";
  echo round($fileSize/1024,2);
  echo "K');";
  echo "location.href='uploadphoto.php?returnid=";
  echo $returnid;
  echo "&fromPage=uploadsave.php";
  echo "'; </script>";
}

//上传友情链接LOGO图    
if($_FILES['imgurl']['name'] != '' && $returnid == "friendlogo") 
{
  $f->savepath = $f->savepath;
  $imgurls = $f->upload('imgurl');
  $kuWebsiteLOGOPath = $imgurls;
  echo "<SCRIPT language=javascript>\n";
  echo "parent.document.myform.friendlinklogo.value='".$imgurls."';\n";
  echo "alert('$promptIncludeDirUploadImgSuccess";
  echo round($fileSize/1024,2);
  echo "K');";
  echo "location.href='uploadphoto.php?returnid=";
  echo $returnid;
  echo "&fromPage=uploadsave.php";
  echo "'; </script>";
}

//上传水印图片
if($_FILES['imgurl']['name'] != '' && $returnid == "wate") 
{ 
  $f->savepath = $f->savepath;
  $imgurls = $f->upload('imgurl');
  $kuWebsiteImgWatePath = $imgurls;
  echo "<SCRIPT language=javascript>\n";
  echo "parent.document.myform.kuWebsiteImgWatePath.value='".$kuWebsiteImgWatePath."';\n";
  echo "alert('$promptIncludeDirUploadImgSuccess";
  echo round($fileSize/1024,2);
  echo "K');";
  echo "location.href='uploadphoto.php?returnid=";
  echo $returnid;
  echo "&fromPage=uploadsave.php";
  echo "'; </script>";
}

//上传Flash图    
if($_FILES['imgurl']['name']!='' && $flash=="flash") 
{ 
  $f->savepath = $f->savepath;
  $imgurls = $f->upload('imgurl');
  echo "<SCRIPT language=javascript>\n";
  echo "parent.document.myform.".$returnid.".value='".$imgurls."';\n";
  echo "alert('$promptIncludeDirUploadImgSuccess";
  echo round($fileSize/1024, 2);
  echo "K');";
  echo "location.href='uploadphoto.php?returnid=";
  echo $returnid;
  echo "&flash=";
  echo $flash;
  echo "'; </script>";  
}
?>
</body>
</html>