Share Code Quickly

What is Harigami?

Harigami is a simple source code sharing service. You can share source code by an URL which is issued after submission.
You can also run your source code online such as Python, Ruby, JavaScript and so on.
For free.Use for code review.
Preferences
anonymous No title
PHP
<!DOCTYPE html>
<html>
<head>
<title>kadai_4 php</title>
</head>
<body>
<form action = "kadai_4.php" mothod = "get">
	<input type = "text" name ="sendtext"><br/>
	<input type ="submit" valude ="送信">
</form>
<?php
	echo "入力されたテキストが下に表示されます<br/>";
	if(isset($_GET["sendtext"])){
		echo $_GET["sendtext"];
	}
?>
</body>
</html>
anonymous No title
PHP
<!DOCTYPE html>
<html>
<head>
<title>kadai_3 php</title>
</head>
<body>
<?php
echo file_get_contents("saveDoc.txt");
?>
</body>
</html>
anonymous No title
PHP
<!DOCTYPE html>
<html>
<head>
<title>kadai_1_2 php</title>
</head>
<body>
<?php
$text = "Kadai_1_2 test OK!";
echo "<p>"."$text"."</p>";
echo '<p>Hello World!</p>';
$fp = fopen("saveDoc.txt","w");
fwrite($fp,"$text");
fclose($fp);
?>
</body>
</html>
anonymous No title
PHP
<!DOCTYPE html>
<html>
<head>
<title>kadai_1 php</title>
</head>
<body>
<?php
$text = "Kadai_1";
echo '<p>Hello World!</p>';
?>
</body>
</html>
anonymous No title
PHP
<!DOCTYPE html>
<html lang="ja" >
  <head>
    <meta charset="UTF-8">
    <title>簡易掲示板</title>
  </head>
  <body>
  <h1>簡易掲示板</h1>
    <form method="post" action="" >
      <p>名前</p>
      <input type="text" name="user_name" required>
      <p>コメント</p>
      <textarea name="comment" rows="4" cols="40"></textarea><br>
      <input type="submit" value="送信">
    </form>
    <?php
   	error_reporting(0);
    	$name=$_POST["user_name"];
   	$comment=$_POST["comment"];
   	$today = date("Y-m-d H:i:s");
   	$filename="kadai_2_2.txt";
   	$num=count(file($filename));
	$num++;
   	fwrite($fp, $num . '<>' . $name . '<>' . $comment . '<>' . $date . "\n");
     	fclose($fp);
    ?>
  </body>
</html>
anonymous No title
PHP
<?php
echo "パスワード、編集番号、削除番号は全て半角で入力してください";
$text_file = "kadai_2_6.txt";
$count_file = "kadai_2_6count.txt";
$date = date("Y-m-d");
$edit_form_number = "";
$edit_form_name = "";
$edit_form_comment = "";
$edit_form_password = "";
if (!empty($_POST["submit_edit"])) {
  $text_file_array_edit = file($text_file);
  $edit_number = $_POST["edit_number"];
  $edit_password = $_POST["edit_password"];
  foreach ($text_file_array_edit as $edit_value) {
    $edit_value_explode = explode("<>",$edit_value);
    if ($edit_value_explode[0] == $edit_number && $edit_value_explode[1] == $edit_password) {
      $edit_form_number = $edit_value_explode[0];
      $edit_form_name = $edit_value_explode[2];
      $edit_form_comment = $edit_value_explode[3];
      $edit_form_password = $edit_value_explode[1];
    }
  }
}
if (!empty($_POST["submit_normal"])) {
  $normal_name = $_POST["normal_name"];
  $normal_comment = $_POST["normal_comment"];
  $normal_password = $_POST["normal_password"];
  $fp = fopen($count_file,"r");
  $count = fgets($fp);
  fclose($fp);
  $count+=1;
  $fp = fopen($count_file,"w");
  fwrite($fp,$count);
  fclose($fp);
  $text_contents_normal = $count . "<>" . $normal_password . "<>" . $normal_name . "<>" . $normal_comment . "<>" . $date . "\n";
  $fp = fopen($text_file,"a");
  fwrite($fp,$text_contents_normal);
  fclose($fp);
  if (!empty($_POST["edit_hidden"])) {
    $text_file_array_edit_contents = file($text_file);
    $edit_hidden = $_POST["edit_hidden"];
    foreach ($text_file_array_edit_contents as &$text_contents_edit) {
      $text_contents_edit_explode = explode("<>",$text_contents_edit);
      if ($text_contents_edite_xplode[0] == $edit_hidden) {
        $text_contents_edit = $edit_hidden . "<>" . $normal_password . "<>" . $normal_name . "<>" . $normal_comment . "<>" . $date . "\n";
      }
    }
    $fp = fopen($text_file,"w");
    fwrite($fp,$text_file_array_edit_contents);
    fclose($fp);
  }
}
if (!empty($_POST["submit_delete"])) {
  $text_file_array_delete = file($text_file);
  $delete_number = $_POST["delete_number"];
  $delete_password = $_POST["delete_password"];
  $text_contents_delete = [];
  foreach ($text_file_array_delete as $delete_value) {
    $delete_value_explode = explode("<>",$delete_value);
    if ($delete_value_explode[0] == $delete_number && $delete_value_explode[1] == $delete_password) {
      continue;
    }else{
      $text_contents_delete[] = $delete_value;
    }
  }
  $fp = fopen($text_file,"w");
  fwrite($fp,implode("",$text_contents_delete));
  fclose($fp);
}
 ?>
 <!DOCTYPE html>
 <html lang="ja">
   <head>
     <meta charset="utf-8">
     <title>簡易掲示板</title>
   </head>
   <body>
     <h1>簡易掲示板</h1>
     <form action="kadai_2_6.php" method="post">
       <input type="hidden" name="edit_hidden" value="<?php echo $edit_form_number; ?>">
       名前:<input type="text" name="normal_name" value="<?php echo $edit_form_name; ?>"><br>
       コメント:<input type="text" name="normal_comment" value="<?php echo $edit_form_comment; ?>"><br>
       パスワード:<input type="text" name="normal_password" value="<?php echo $edit_form_password; ?>"><br>
       <input type="submit" name="submit_normal" value="投稿">
    </form>
    <h1>削除フォーム</h1>
    <form action="kadai_2_6.php" method="post">
      削除番号:<input type="text" name="delete_number"><br>
      パスワード:<input type="text" name="delete_password"><br>
      <input type="submit" name="submit_delete" value="削除する">
    </form>
    <h1>編集フォーム</h1>
    <form action="kadai_2_6.php" method="post">
      編集番号:<input type="text" name="edit_number"><br>
      パスワード:<input type="text" name="edit_password"><br>
      <input type="submit" name="submit_edit" value="編集する">
    </form>
    <?php
     $text_file_array_display = file($text_file);
     foreach ($text_file_array_display as $display_value) {
       $display_value_explode = explode("<>",$display_value);
       echo $display_value_explode[0] . " " . $display_value_explode[2] . " " . $display_value_explode[3] . " " . $display_value_explode[4] . "<br>";
     }
     ?>
   </body>
 </html>
anonymous No title
PHP
<?php
    $filename = "kadai_2_5.txt";
    $lines = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
    $editNumber = '';
    $editName = '';
    $editComment = '';
    if(isset($_POST["edit"])) {
        foreach($lines as $row) {
            $bbsRowData = explode("<>", $row);
            if($bbsRowData[0] == $_POST["number"]) {
                $editNumber = $bbsRowData[0];
                $editName = $bbsRowData[1];
                $editComment = $bbsRowData[2];
                break;
            }
        }
    }
    else if(isset($_POST["normal"])) {
        $now_date=date("Y-m-d");
        $writeData = ($_POST['edit_post'] ?: count($lines) + 1) . "<>" . $_POST['name'] . "<>" . $_POST['comment'] . "<>" . $now_date;
        if($_POST["edit_post"]) {
            foreach($lines as &$row) {
                $bbsRowData = explode("<>", $row);
                if($bbsRowData[0] == $_POST["edit_post"]) {
                    $row = $writeData;
                }
            }
        }
        else {
            $lines[] = $writeData;
        }
     file_put_contents($filename, implode("\n", $lines));
    }
?>
<!doctype html>
<html lang="ja">
 <head>
  <meta charset="UTF-8">
  <title>簡易掲示板</title>
 </head>
 <body>
  <h1>簡易掲示板</h1>
  <form action="kadai_2_5.php" method="POST">
   <input type="hidden" name="edit_post" value="<?php echo $editNumber; ?>">
   名前:<input type="text" name="name" value="<?php echo $editName; ?>">
   <br />
   コメント:<input name="comment" value="<?php echo $editComment; ?>">
   <br />
   <input type="submit" name="normal" value="送信">
  </form>
  <h1>編集用フォーム</h1>
  <form action="kadai_2_5.php" method="POST">
   編集番号:<input type="text" name="number">
   <input type="submit" name="edit" value="送信">
  </form>
  <?php
  $ret_array=file($filename);
  foreach ($ret_array as $value) {
    $file_array=explode("<>",$value);
    foreach ($file_array as $value_array) {
      echo($value_array."<br />\n");
    }
  }
   ?>
 </body>
</html>
anonymous No title
PHP
<!DOCTYPE html>
<html lang="ja">
<head>
  <meta charset="utf-8">
  <title>簡易掲示板</title>
</head>
<body>
  <h1>簡易掲示板</h1>
  <form action="" method="POST">
    <p>名前 <br>
      <input type="text" name="name">
    </p>
    <p>コメント <br>
      <input type="text" name="comment">
    </p>
    <p><input type="submit" value="送信"></p>
  </form>
  <?php
  $filename = "kadai_2_4.txt";
  if (!empty($_POST["name"]) && isset($_POST["comment"])) {
    $name = $_POST["name"];
    $comment = $_POST["comment"];
    if (file_exists($filename)) {
      $num = count(file($filename)) + 1;
    } else {
      $num = 1;
    }
    $date = date("Y-m-d");
    $str = $num . "<>" . $name . "<>" . $comment . "<>" . $date . "\n";
    $fp = fopen($filename, "a");
    fwrite($fp, $str);
    fclose($fp);
  }
  ?>
  <h1>削除フォーム</h1>
  <form action="" method="POST">
    <p>削除番号 <br>
      <input type="number" name="delete">
    </p>
    <p><input type="submit" value="削除"></p>
  </form>
  <?php
  $filename = "kadai_2_4.txt";
  if (!empty($_POST["delete"])) {
    $delete = $_POST["delete"];
    $num = file($filename);
    $fp = fopen($filename, "w");
    foreach ($num as $line) {
      $lines = explode("<>", $line);
      if ($delete !== $line[0]) {
        fwrite($fp, $line);
      }
    }
    fclose($fp);
  }
  ?>
  <?php
  $filename = "kadai_2_4.txt";
  $ret_array = file("$filename");
  foreach ($ret_array as $value) {
    $texts = explode("<>", $value);
    echo $texts[0];
    echo $texts[1];
    echo $texts[2];
    echo $texts[3];
    echo "<br/>";
  }
  ?>
</body>
</html>
anonymous No title
PHP
<!DOCTYPE html>
<html lang="ja" >
<!--head文を記入します-->
  <head>
    <meta charset="utf-8">
    <title>名前とコメント欄の表示</title>
  </head>
<!--body文の始まり-->
  <body>
    <form action="" method="post">
      <!--名前の欄を作る-->
      <p>名前</p>
      <input type="text" name="user_name"><br>
      <!--コメント欄を作ります-->
      <p>コメント</p>
      <textarea name="comment" rows="4" cols="40"></textarea><br>
      <!--送信ボタンの取り付け-->
      <input type="submit" value="送信">
    </form>
<?php
//エラー表示をなくします
error_reporting(0);
   //名前を変数に
    $name=$_POST["user_name"];
   //コメントを変数に
   $comment=$_POST["comment"];
   //時間の設定
   $date=date("Y-m-d H:i:s");
   //ファイルネイムの設定
   $filename="kadai_2_3.txt";
   //投稿番号の設定
   $num=count(file($filename))+1;
   //これらを繋げます
   $parts="$num<>$name<>$comment<>$date";
   //ファイルを開きます
   $fp=fopen($filename,"a");
   //名前、コメントどっちもからの時
   if(empty($name) && empty($comment)){
       echo "未記入箇所があります。<br>";
   }
   //名前がからの時
   elseif(empty($name) ){
       echo "名前を入力してください<br>";
   }
   //文章がからの時
   elseif(empty($comment)){
       echo "コメントを入力してください<br>";
   }
   //どっちも入ってるとき
   elseif(isset($name) && isset($comment)){
     fwrite($fp,"$parts".PHP_EOL);
     fclose($fp);
   }
   //フォームに取得したデータを表示する
   if(file_exists($filename)){
     //FILE_IGNORE_NEW_LINESは配列の各要素の最後の改行を省略
     $lines=file($filename,FILE_IGNORE_NEW_LINES);
     foreach($lines as $line){
       //explodeで分割
       list($num,$name,$comment,$date)=explode("<>",$line);
       //echoで表示
       echo "$num<>$name<>$comment<>$date"."<br>";
     }
   }
?>
  </body>
</html>
anonymous No title
PHP
<!DOCTYPE html>
<html lang="ja" >
<!--head文を記入します-->
  <head>
    <meta charset="utf-8">
    <title>名前とコメント欄</title>
  </head>
<!--body文の始まり-->
  <body>
    <form action="" method="post">
      <!--名前の欄を作る-->
      <p>名前</p>
      <input type="text" name="user_name"><br>
      <!--コメント欄を作ります-->
      <p>コメント</p>
      <textarea name="comment" rows="4" cols="40"></textarea><br>
      <!--送信ボタンの取り付け-->
      <input type="submit" value="送信">
    </form>
   <?php
   //エラー表示をなくします
   error_reporting(0);
   //名前を変数に
    $name=$_POST["user_name"];
   //コメントを変数に
   $comment=$_POST["comment"];
   //時間の設定
   $date=date("Y-m-d H:i:s");
   //ファイルネイムの設定
   $filename="kadai_2_2.txt";
   //投稿番号の設定
   $num=count(file($filename))+1;
   //これらを繋げます
   $parts="$num<>$name<>$comment<>$date";
   //ファイルを開きます
   $fp=fopen($filename,"a");
   //名前、コメントどっちもからの時
   if(empty($name) && empty($comment)){
       echo "未記入箇所があります。<br>";
   }
   //名前がからの時
   elseif(empty($name) ){
       echo "名前を入力してください<br>";
   }
   //文章がからの時
   elseif(empty($comment)){
       echo "コメントを入力してください<br>";
   }
   //どっちも入ってるとき
   elseif(isset($name) && isset($comment)){
     fwrite($fp,$parts.PHP_EOL);
     fclose($fp);
   }
    ?>
  </body>
</html>