<?php
/*
  power by JASON.ZHANG  DM建站  www.demososo.com
*/
if(!defined('IN_DEMOSOSO')) {
  exit('this is wrong page,please back to homepage');
}
?>
 
<?php

$sql="select * from  ".TABLE_ALBUM."  where  pid='$pid'   and id='$tid' $andlangbh order by id limit 1";
  //echo $sql;exit;
   $row = getrow($sql);
   //pre($row);
   
      $addr_cus = $imgsqlname = $row['kvsm'];
      
$imgsmall = p2030_imgyt($imgsqlname,'n','y') ;

$delimg = '';
//$imgv2 = '';
  $jumpvback =  $jumpv.'&file=edit&tid='.$tid.'&act=edit'; 
   
  if($imgsqlname<>''){
      
     // $imgv2   = p2030_imgyt($imgsqlname,'y','n'); //p2030_imgyt($addr,$w_h='y',$linkbig='n')
    //del(actgo2,pidname,backpage,title)
      $delimg= "<br /> <a href=javascript:del('delimg','$tid','$jumpvback','')  class='but2'>删除图片</a><br /> <br /> ";
   }


 
if($act=="update"){
 // pre($_POST); 

   $imgcus = 'n'; 
    $desp=zbdesp_onlyinsert($_POST['desp']); 
 


  $ifwater=@htmlentitdm($_POST['water']);
  if($ifwater=='y') $up_water='y';
     else $up_water='n';
     
  $imgname=$_FILES["addr"]["name"] ;
   $imgsize=$_FILES["addr"]["size"] ;
  
   $kv_v = '';



   //echo $up_water;exit;
 
  if(!empty($imgname)){
    $sql = "SELECT kvsm from ".TABLE_ALBUM." where pid='$pid'   and id='$tid' $andlangbh   limit 1";
   // echo $sql;exit;
    $rowss = getrow($sql);
    $addr_cus = $imgsqlname =   $rowss['kvsm'];
    $imgtype = gl_imgtype($imgname);
    
     $up_w_s=$album_s_w; $up_h_s=$album_s_h;
   if($up_w_s>600) $up_w_s=600;elseif($up_w_s<60) $up_w_s=60;
   if($up_h_s>600) $up_h_s=600;elseif($up_h_s<60) $up_h_s=60;
   
    $up_small='y';
    $up_add_s='y';
    $up_delbig='n'; 
     $i='';

  
    require_once('../plugin/upload_img.php');//need get the return value,then upimg part turn to easy.
    
    $kv_v = ",kvsm = '$return_v'";

    
      $ss = "update ".TABLE_ALBUM." set title='$abc1'$kv_v,desp='$desp' where pid='$pid'  and id='$tid' $andlangbh  limit 1";
       //echo $ss;exit;
      iquery($ss);  


  }//end not empty
  else{
         $imgcus='y';
             // alert('没有上传图片。');

             
       }

         if($imgcus=='y'){
               
              $addr_cus=@htmlentitdm($_POST['addr_cus']);
               $short_add_cus = substr($addr_cus, 0,4);

               $where2 = '';
              if($short_add_cus=='http' || $short_add_cus == 'uplo') { 
                $where2 = " ,kvsm='$addr_cus' ";
                
               }

        $ss = "update ".TABLE_ALBUM." set title='$abc1',desp='$desp' $where2 where pid='$pid'  and id='$tid' $andlangbh  limit 1";   
                
                  //echo $ss;
                   iquery($ss); 

            
          }
  


  // $jumpv_back = $jumpv_file.'&act=edit&tid='.$tid;
      //echo $jumpv_back;exit;
    
       jump($jumpvback);



}
else if($act=='delimg'){
  
       if($imgsqlname<>'') p2030_delimg($imgsqlname,'y','y');//p2030_delimg($addr,$delbig,$delsmall)

       $ss = "update ".TABLE_ALBUM."  set  kvsm=''   where id='$tid' $andlangbh limit 1";
      iquery($ss);
      jump($jumpvback);
    }

else{
   
$updatelink =  $jumpv_file.'&act=update&tid='.$tid;
 
   ?>
<div class="layoutsidebar fl col-xs-12 col-sm-12  col-md-2">
<?php 
 require_once HERE_ROOT.'mod_album/tpl_album_edit_sidebar.php';

 ?>
</div><!--end sidebar-->
<div class="fl col-xs-12 col-sm-12  col-md-10">
<form   action="<?php echo $updatelink;?>" method="post" enctype="multipart/form-data">
  <table class="formtab">
    <tr>
      <td width="12%" align="right">图片名称(可不填)：</td>
      <td width="88%"> <input name="name" type="text" id="name" value="<?php echo $row['title']?>" class="form-control" />
      </td>
    </tr>
          <tr>
      <td align="right">图片说明内容（可不填）：</td>
      <td>
<textarea  class="form-control"  rows="8"  name="desp">
<?php  
echo  zbdespedit($row['desp']);
?>
</textarea>
</td>
    </tr>

  <tr>
      <td align="right">图片：
   <?php echo $delimg?>
      </td>
      <td><input name="addr" type="file" class="form-control" />

      <?php

      ?>

       <br />
      <?php
      $addr_cus_2 = substr($addr_cus,0,4);
     
      if($addr_cus_2=='http' || $addr_cus_2=='zsta' || $addr_cus_2=='uplo'){ }
        else{
          echo '<br /><span class="cred">要修改的图片的扩展名必须一致。否则缩略图不会变化！<br />'.$format_t.'</span><br />';
   
       echo $imgsmall;
        }
       
      ?>


      </td>
    </tr>

  <tr>
            <td   align="right"  >添加水印：</td>
            <td > 
            <input type="checkbox" name="water" id="water" value="y" checked="checked" size="10">
            <label for="water">加上水印</label>
             
            </td>
          </tr>


       <tr>
      <td class="tr">  自定义图片：</td>
      <td>
        <?php 
 
$disable =  '';
$custext = '';
  //echo $imgsqlname;
if($imgsqlname<>'') {

 
           $short_add_cus = substr($imgsqlname, 0,4);
          if($short_add_cus=='http' || $short_add_cus == 'uplo') {  } 
            else {
                $disable = "disabled";
                 $custext = '如果要自定义图片，请先删除上面上传的图片。<br />';
            } 

  

}

?>
<input name="addr_cus" <?php echo $disable?> type="text" value="<?php echo $addr_cus?>" class="form-control"  />
        <p><?php echo $custext;?>自定义图片的格式：http或https或upload开头 </p>
        <?php 

        if($short_add_cus=='http' || $short_add_cus == 'uplo') { 
        text_cusimg($addr_cus); 
         } 
        
        ?>
      </td>
    </tr>


  

          <tr>
      <td></td>
      <td>
      <input class="mysubmit"  type="submit" name="Submit" value="修改" />
      </td>
    </tr>

  </table>
</form>

</div>
<div class="c"></div>

<?php }

?> 