Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
1
10php
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yu Kimiduka
10php
Commits
94206d33
Commit
94206d33
authored
Jul 13, 2016
by
君塚 悠
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
プログラム作製(guest_write_r2.php;ゲストブック書き込み)
parent
0652266e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
0 deletions
+64
-0
guest_write_r2.php
php/php10/day05/guest_write_r2.php
+34
-0
data.dat
php/php10/day06-1/data.dat
+2
-0
rss_output.php
php/php10/day06-1/rss_output.php
+28
-0
No files found.
php/php10/day05/guest_write_r2.php
0 → 100644
View file @
94206d33
<?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
php/php10/day06-1/data.dat
0 → 100644
View file @
94206d33
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/php10/day06-1/rss_output.php
0 → 100644
View file @
94206d33
<?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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment