<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>DM建站系统</title>
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="author" content="DM建站系统 www.demososo.com" />
<meta name="viewport" content="initial-scale=1.0, minimum-scale=1.0, maximum-scale=2.0, user-scalable=no, width=device-width">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible" />
</head>
<body>

<?php 


if(!dmlogin()){
  echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
  echo '提示：没有登录后台 ';
    //fnoid();
  exit;
}

//编辑静态文本---一般是首页的。
//TPLCURROOT.'data/'.$file'.php'

 //  echo $pidname;
//jttextexist($type,$pidname)
 

  $datafile = jtdatafilexist($pidname,$pidname2);
      if(!is_file($datafile)){
        echo '<p class="errorfont">保存数据文件：......'.substr($datafile,-60).'  not exist</p>';
        
      }
   
 

$arr  = require $datafile;
 // pre($arr);


$length = count($arr);
if($length==0) {
	echo 'array length is zero';
	exit;
}

 
$jump = BASEURL.'dmpostform.php?type=editjtmbtext&pidname='.$pidname.'&pidname2='.$pidname2.'&lang='.LANGPATH;

 

?>



<?php 
   
  
  if($act=='update'){

  		//每年操作前，先备份下。
  	     // copy($file,$filebak);

 
  		 $postarr = $_POST;
  		 $str = '';
       pre($postarr);
  		 foreach ($postarr as $k => $v) {
           $v = trim($v);

        //  if(substr($k,0,7)=='jttext_') {
        //     $str .= "'$k'=>'".addslashes($v)."',\n";
        //  }
        //  else{
        //     $str .= "'".addslashes($v)."',\n";
        //  }
        $str .= "'$k'=>'".dmjtinput1($v)."',\n";

  		 	 
  		 	  
  		 }
  		 $str = "<?php return array (".substr($str,0,-1).");";
  		 //echo $str;
  		 file_put_contents($datafile,$str);
  		// jump($jump);

  }
?>



<div class="popeditjttext">
 <div class="hd">编辑文本：</div>
 
<form   action="<?php echo $jump?>&act=update" method="post">
	 
	<?php 
  $i = -1;
		foreach ($arr as $k => $v) {
      $i++;
      $value = $arr[$k];
			$v2 = dmjtinput2($arr[$k]);

      $hd = '';
      $hdstyle = '';
      if(substr($value,0,8)=='##:--##:'){

        $hd = str_replace('##:--##:', '', $value);
        $hd = '<strong>'.$hd.'</strong>';
        $hdstyle = ' style = "display:none"';

      }
       if(substr($value,0,8)=='#:line:#'){
      
        $hd = '<strong>分隔线</strong>';
        $hdstyle = ' style = "display:none"';

      }

      if(is_numeric($k)) {
        $k = $k+1;
        $tit = 'jttext'.$k;
        $namev = $tit;
      }
      else{
         $tit = $k;
         $namev = $k;
      }
       


			echo '<div class="popline"><span>'.$tit.' : </span>'.$hd.'<textarea '.$hdstyle.' name="'.$namev.'" cols="80" rows="2">'.$v2.'</textarea></div>';
		}
	?>
	<div class="submit">
		 <button type="submit">编辑</button>

	</div>


</form>
</div>

<style>
	body{background: #fff}
.popeditjttext {margin:0 auto;width:60%;padding:30px 0;font-size: 12px}
.popeditjttext textarea{width: 100%}
.popeditjttext .hd{font-weight: bold;margin-bottom: 15px;font-size: 16px}
.popeditjttext .popline{ display: block;margin-bottom:15px;position: relative;padding-left: 90px }
.popeditjttext .popline span{ position: absolute;top:10px;left: 0; }
.popeditjttext .popline strong{font-size: 16px;color:#008ED6;}

.popeditjttext .submit{padding:20px;text-align: center;}
.popeditjttext .submit button{padding:10px 50px;font-size:16px; cursor: pointer;background: #008ED6;color:#fff;border:0;}
.popeditjttext .submit button:hover{background: #067db9}
</style>

</body></html>