<?php
  include("./control/session.inc");

function form()
{

  $name = $_GET['name'];
  $oprt = $_GET['oprt'];
  include("./content/html_tag/$name.inc");
  if($oprt == "1"){
  $h2 = '【'.$name.'】　htmlソースの確認';
  $bt = '';
  }elseif($oprt == "2"){
  $h2 = '【'.$name.'】　htmlソースの編集';
  $bt = '<input type="hidden" name="c1" value="1"><input type="submit" value="Creating" class="s_button">';
  }

  $c1 = $_POST['c1'];
  $title = $_POST['title'];
  $new_tag = $_POST['new_tag'];
  $c_text = <<<KOEY
<?php
  \$content = <<<EOD
$new_tag
EOD;
?>
KOEY;

  $main1 = <<<EOD
<div id="main_r1">
<h2>{$h2}</h2>
EOD;

  $form = <<<EOD
<form action="AYANASU_control.php?cname=creating_tagr&oprt=2&name=$name" method="post">
<div id="form_box1">
<div id="form_box2"><div class="fi-page-edit"> HTMLタグの内容</div></div>
<textarea name="new_tag">$content</textarea>
</div>
$bt
</form>
</div>
EOD;

  if($_POST['c1'] ==""){
  print $main1;
  print $form;
  }else{

  $gif_an = <<<EOD
<div id="main_r1">
<h2>htmlタグの保存中です</h2>
<div class="loader"></div>…Creating
<br>
</div>
EOD;
  print("$gif_an");

  $dire = "./content/html_tag"; 
  $l_name = $name.'.inc';
  $file = $dire.'/'.$l_name;
  file_put_contents($file,$c_text,LOCK_EX);
  header("Refresh: 2; URL=./AYANASU_control.php?cname=creating_tagr&oprt=2&name=$name");
  }

}
?>
