<?php

/*----------仅限pc端样式 only pc style---------*/
//@media (min-width: 801px) {

//}
/*----------仅限mobile端样式 only mobile style---------*/
//@media (max-width: 800px) {
//}

$sql = "SELECT htmldir from ".TABLE_STYLE."  where  pidname='$pidname' $andlangbh   order by id limit 1";
$row = getrow($sql);
$htmldir=$row['htmldir'];



//$cssfilename = $htmldir .'/cssjs/'.$htmldir.'.css';
//$cssfile = TEMPLATEROOT.$cssfilename;

$cssfilename = 'assets/cssjstpl/'.$pidname.'.css';  //not use curstyle...
$cssfile = STAROOT.$cssfilename;


$cssbak = WEB_ROOT .'cache/cssbak/'.date("Ymd-His").'--'.$pidname.'.css';
//echo $cssbak;
$csslink = '';
if(is_file($cssfile))  $csslink = ' <a target="_blank" href="'.STAPATH.$cssfilename.'?v='.rand(1111,9999).' ">查看css <i class="fa fa-external-link-square"></i></a>';

 echo '<h3 style="font-size:18px">自定义css - 来自 DM-static/'.$cssfilename. $csslink.'</h3>';

 if($act=='create'){

  if(!is_file($cssfile))  fopen($cssfile, "w");

  $jumpv = $jumpv_pf.'&act=edit';

  jump($jumpv);


}

else if($act=='delsql'){


  unlinkdm($cssfile);

  $jumpv = $jumpv_pf.'&act=edit';

 jump($jumpv);


}



else if(!is_file($cssfile)) {
  echo '对不起，此文件不存在。';
  $jumpv_insert = $jumpv_pf.'&act=create';
  echo  '<a class="but1" href="'.$jumpv_insert.'">创建</a>';
}


else{


  $desp=file_get_contents($cssfile);


//---------------------
if($act=='update'){



   if(@$_POST['inputmust']=='') {echo $inputmusterror.$backlist;exit;}


//----change cssversion---------------
$cssversion = rand(1111,9999);
$ss = "update ".TABLE_LANG." set cssversion='$cssversion'  where lang='".LANG."' limit 1";
// echo $ss;exit;
iquery($ss);

//-----------------

   $despv = $_POST['desp'];

   $despv=str_replace("<script>","<-nojsscript->",$despv);
   $despv=str_replace("</script>","<-nojsscript->",$despv);
   $despv=str_replace("<?","<-nojsscript->",$despv);
   $despv=str_replace("<?php","<-nojsscript->",$despv);


   $jumpv = $jumpv_pf.'&act=edit';


     // if(strlen($despv)<10){
       // alert('字符不够。');
       // jump($jumpv);
     // }
     // else{
        file_put_contents($cssfile,$despv);

        if(!is_file($cssbak)) fopen($cssbak, "w");
        file_put_contents($cssbak,$despv);

        jump($jumpv);
      //}



}
else{



$jumpv_insert = $jumpv_pf.'&act=update';
?>

<form  onsubmit="javascript:return checkhere(this)" action="<?php echo $jumpv_insert;?>" method="post">
  <table class="formtab">

    <tr>
      <td  width="20%"  class="tr"> css文件：

      <br />

      <?php


$jsname = '';
$tid='';

      $del_text= " <a href=javascript:delid('delsql','$tid','$jumpv_pf','$jsname')  class=but2><i class='fa fa-trash-o'></i> 删除</a>";
      echo $del_text;

?>
      </td>
      <td >
      <br/>


  <textarea  style="height:650px" name = "desp"  class="form-control"><?php echo $desp;?></textarea>

  </td>
    </tr>


  <tr>
      <td></td>
      <td>
      <p class="cgray">提示：这里的每次提交，都会在<a class="needpopup"  href="mod_cachecss.php?lang=<?php echo LANG;?>">cache/cssbak</a>目录下产生备份文件。可以通过ftp定期清理这些文件。<br /></p>

      <input  class="mysubmit" type="submit" name="Submit" value="提交" />

    </td>
    </tr>


    </table>

    <?php echo $inputmust;?>

</form>
<?php }
?>
<script>
function checkhere(thisForm) {

}

</script>

<?php
}

?>
