<?php
  include("./control/session.inc");
  $c1 = $_POST['c1'];

function form()
{

  $name = $_GET['name'];
  $file_name = $name.'.inc';
  $dir = './content/linkGroup/';
  $file = $dir.$file_name;
  $tag = highlight_string('<?php include ("'.$file.'"); ?>',TRUE);

  if($_POST['c1'] =="1"){

  $r_content = $_POST['content'];

  $gif_an = <<<EOD
<div id="main_r1">
<h2>【{$file_name}】の保存中です</h2>
<div class="loader"></div>…Creating
</div>
EOD;
  print("$gif_an");

  //書き出し
  file_put_contents($dir.$file_name,$r_content,LOCK_EX);
  $file=$dir.$file_name;
  header("Refresh: 2; URL=AYANASU_control.php?cname=creating_linkr&name={$name}");

  }elseif($_POST['c1'] ==""){
  $content = file_get_contents($dir.$file_name);

  $form = <<<EOD
<div id="main_r1">
<h2>リンクグループ【{$file_name}】の編集</h2>
<form action="AYANASU_control.php?cname=creating_linkr&name={$name}" method="post">

<div id="form_box1">
<div id="form_box2"><div class="fi-page-edit"> {$file_name}</div></div>
<br>
貼り付けタグ：{$tag}
<textarea name="content">$content</textarea>
<input type="hidden" name="c1" value="1">
<input type="submit" value="Creating" class="s_button">
</div>
</form>
</div>
EOD;

  print $form;
  }
}
?>