Commit 94206d33 authored by 君塚 悠's avatar 君塚 悠

プログラム作製(guest_write_r2.php;ゲストブック書き込み)

parent 0652266e
<?php
//オリジナルファイルの読み込み
$org_file=fopen("guest.dat", "r");
//tmpファイルの作成→新記書き込み→オリジナルファイル追記
$tmp_file=fopen("guest/tmp", "w");
//ファイルをロック(他ユーザが編集できなくなる
flock($org_file,LOCK_EX);
flock($tmp_file,LOCK_EX);
//$line変数に書き込む文字列を連結していく。\tはタブ。
$line =date("Y年 m月 d日 H:i:s")."\t";
$line.=$_POST['name']."\t";
$line.=$_POST['message']."\t";
//tmpファイルに打った内容を書き込み
fputs($file,$line."\n");
//tmpファイルに既存の書き込みを追記
while ($row = gets($org_file, 1024)) {
fputs("$tmp_file", $row);
}
//ファイルのロックを解除、クローズ
flock($org_file,LUCK_UN);
flock($tmp_file,LUCK_UN);
fclose($org_file);
fclose($tmp_file);
//オリジナルファイル削除→tmpをオリジナルにリネーム
unlink("guest.dat");
rename("guest.tmp", "guest.dat");
header("Location: guest_input.php");
?>
\ No newline at end of file
http://www.wings.msn.to/index.php/-/A-03/4-7980-0945-8/ 今日から使えるPHP5サンプル集 PHP 最新のPHP5.xに対応し、初心者から上級者まで、ますます使えるサンプル集。CD-ROMと連動した豊富な実用サンプルで簡単PHPサイト作成。
http://www.wings.msn.to/index/ph/-/ A-03/4-7981-0883-9/ Samary入門 PHP 待望のSamary入門書。 PHPユーザー必読!ロジックとウェブデザインの架け橋、デンプレート・エンジンSmaryを極めよう。
\ No newline at end of file
<?php
//外部ライブラリのインクルード
require_once("rss10.inc");
//RSSWritesオブジェクト作成
$objRss = new RSSWriter("http://www.wings.msn.to/",
"サーバサイド技術の学び舎 - WINGS", "サーバサイド技術に関する最新情報",
array(
"dc:pblisher" => "YAMADA, Yoshihiro",
"dc:creator"=> "YAMADA, Yoshihiro <CQW15204@nifty.com>"
));
//サマリ情報の登録
$objRss -> setImage("http://www.wings.msn.to/image/wings.jpg",
"サーバサイド技術の学び舎 - WINGS", 150, 90);
$file = fopen ("data.dat", "r");
while ($row = fgets ("file, 1024")) {
$datum = explode("\t", $row);
$objRss -> addItem ($datum[0], $datum[1],
array("description" => $datum[3], "dc:subject" => $datum[2]));
}
fclose($file);
//RSS文書出力
$objRss -> serialize();
?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment