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

function form()
{

  $r_name = $_GET['name'];
  if($_GET['name'] =='thema'){$file_name = 'thema.php';}else{$file_name = $r_name.'.css';}

  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");

    //書き出し
  $r_dir = './thema/';
  file_put_contents($r_dir.$file_name,$r_content,LOCK_EX);
  header("Refresh: 2; URL=AYANASU_control.php?cname=creating_thema&name={$r_name}");

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

  $form = <<<EOD
<div id="main_r1">
<h2>{$file_name}の編集</h2>
<form action="AYANASU_control.php?cname=creating_thema&name={$r_name}" method="post">
<div id="form_box1">
<div id="form_box2"><div class="fi-page-edit"> {$file_name}</div></div>
<a href="./index.php" target="_blank" class="but1"><div class="fi-magnifying-glass"> INDEX</div></a>
<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;
  }

}

?>