質問編集履歴
3
ソースの訂正
test
CHANGED
File without changes
|
test
CHANGED
@@ -23,50 +23,6 @@
|
|
23
23
|
###該当のソースコード
|
24
24
|
|
25
25
|
```
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
ーーーindex.hhtmlーーー
|
30
|
-
|
31
|
-
<form name="form1" action="./x.php" method="POST">
|
32
|
-
|
33
|
-
ページタイトル:<br />
|
34
|
-
|
35
|
-
<input type="text" name="pagetitle" size="70" value=""/><br />
|
36
|
-
|
37
|
-
キーワード:<br />
|
38
|
-
|
39
|
-
<input type="text" name="keyword" size="70" value=""/><br />
|
40
|
-
|
41
|
-
ディスクリプション:<br />
|
42
|
-
|
43
|
-
<textarea name="dis" rows="3" cols="70"/></textarea><br />
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
<input type="text" name="gaurl" size="70"value="XXXXXXXXXXXXXXXXXXXXXXX"><br />
|
48
|
-
|
49
|
-
<br />
|
50
|
-
|
51
|
-
サブタイトル:<br />
|
52
|
-
|
53
|
-
<input type="text" name="sabutitle" size="70" value=" "/><br />
|
54
|
-
|
55
|
-
本文<br />
|
56
|
-
|
57
|
-
<textarea name="honbun" rows="6" cols="70" >
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
</textarea><br />
|
62
|
-
|
63
|
-
画像下本文(画像の下にここに記入した文字が入ります)<br />
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
<input type="submit" value="送信" />
|
68
|
-
|
69
|
-
</form>
|
70
26
|
|
71
27
|
|
72
28
|
|
@@ -98,121 +54,11 @@
|
|
98
54
|
|
99
55
|
}
|
100
56
|
|
101
|
-
}
|
57
|
+
}
|
102
58
|
|
103
59
|
|
104
60
|
|
105
|
-
$template = "temp.php"; // テンプレートファイル名
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
if ($_POST{"honbun"}) {
|
110
|
-
|
111
|
-
// ※1 POSTデータを全て受け取りエスケープして変数に入れる
|
112
|
-
|
113
|
-
foreach($_POST as $k => $v) {
|
114
|
-
|
115
|
-
if(get_magic_quotes_gpc()) { $v=stripslashes($v); }
|
116
|
-
|
117
|
-
// $v=htmlspecialchars($v);
|
118
|
-
|
119
|
-
$array[$k]=$v;
|
120
|
-
|
121
|
-
}
|
122
|
-
|
123
|
-
extract($array);
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
// 文字コードはUTF-8
|
128
|
-
|
129
|
-
$keyword = mb_convert_encoding($keyword, "UTF-8","AUTO");
|
130
|
-
|
131
|
-
$dis = mb_convert_encoding($dis, "UTF-8","AUTO");
|
132
|
-
|
133
|
-
$gaurl = mb_convert_encoding($gaurl, "UTF-8","AUTO");
|
134
|
-
|
135
|
-
$sabutitle = mb_convert_encoding($sabutitle, "UTF-8","AUTO");
|
136
|
-
|
137
|
-
$honbun = mb_convert_encoding($honbun, "UTF-8","AUTO");
|
138
|
-
|
139
|
-
$honbun1 = mb_convert_encoding($honbun1, "UTF-8","AUTO");
|
140
|
-
|
141
|
-
$pagetitle = mb_convert_encoding( htmlspecialchars($pagetitle), "UTF-8","AUTO");
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
// 改行を<br>タグに変換
|
148
|
-
|
149
|
-
$honbun = nl2br($honbun);
|
150
|
-
|
151
|
-
$honbun1 = nl2br($honbun1);
|
152
|
-
|
153
|
-
$dis = nl2br($dis);
|
154
|
-
|
155
|
-
$keyword = nl2br($keyword);
|
156
|
-
|
157
|
-
$sabutitle = nl2br($sabutitle);
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
// 時間をファイル名に
|
166
|
-
|
167
61
|
$filename = date("YmdHis").$_FILES['userfile']['name'] . ".html";
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
// ※2 メッセージ表示
|
172
|
-
|
173
|
-
if (createNewPage( $filename, $template, $pagetitle, $keyword, $dis, $sabutitle, $gaurl, $honbun, $honbun1)) {
|
174
|
-
|
175
|
-
echo '<a href="'.$dirname.$filename.'">http://ーーーーー.jp/beta/'.$dirname.$filename.'</a>'."を生成し、書き込みを行いました。";
|
176
|
-
|
177
|
-
} else {
|
178
|
-
|
179
|
-
echo "ファイルの生成に失敗しました。";
|
180
|
-
|
181
|
-
}
|
182
|
-
|
183
|
-
} else {
|
184
|
-
|
185
|
-
echo "フォームから記事の内容を送信してください。";
|
186
|
-
|
187
|
-
}
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
// ※3 ページ生成関数 createNewPage()
|
192
|
-
|
193
|
-
function createNewPage( $filename, $template, $pagetitle, $keyword, $dis, $sabutitle, $gaurl, $honbun, $honbun1 ) {
|
194
|
-
|
195
|
-
// ※4 テンプレートファイルの読み込み
|
196
|
-
|
197
|
-
if ( ($contents = file_get_contents( $template)) == FALSE) { return false; }
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
// タイトルと記事本文を挿入
|
202
|
-
|
203
|
-
$contents = str_replace( "<%PAGETITLE>", $pagetitle, $contents);
|
204
|
-
|
205
|
-
$contents = str_replace( "<%PAGECONTENTS>", $honbun, $contents);
|
206
|
-
|
207
|
-
$contents = str_replace( "<%PAGECONTENTS1>", $honbun1, $contents);
|
208
|
-
|
209
|
-
$contents = str_replace( "<%PAGEKEYWORD>", $keyword, $contents);
|
210
|
-
|
211
|
-
$contents = str_replace( "<%PAGEDIS>", $dis, $contents);
|
212
|
-
|
213
|
-
$contents = str_replace( "<%PAGESABUTITLE>", $sabutitle, $contents);
|
214
|
-
|
215
|
-
$contents = str_replace( "<%PAGEGAURL>", $gaurl, $contents);
|
216
62
|
|
217
63
|
|
218
64
|
|
@@ -223,16 +69,6 @@
|
|
223
69
|
if ( ($handle = fopen( $dirname . $filename, 'w')) == FALSE) { return false; }
|
224
70
|
|
225
71
|
|
226
|
-
|
227
|
-
fwrite( $handle, $contents);
|
228
|
-
|
229
|
-
fclose( $handle );
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
return true;
|
234
|
-
|
235
|
-
|
236
72
|
|
237
73
|
}
|
238
74
|
|
2
一部修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -172,7 +172,7 @@
|
|
172
172
|
|
173
173
|
if (createNewPage( $filename, $template, $pagetitle, $keyword, $dis, $sabutitle, $gaurl, $honbun, $honbun1)) {
|
174
174
|
|
175
|
-
echo '<a href="'.$dirname.$filename.'">http://
|
175
|
+
echo '<a href="'.$dirname.$filename.'">http://ーーーーー.jp/beta/'.$dirname.$filename.'</a>'."を生成し、書き込みを行いました。";
|
176
176
|
|
177
177
|
} else {
|
178
178
|
|
1
すべてのソースを表示します。
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,7 +24,59 @@
|
|
24
24
|
|
25
25
|
```
|
26
26
|
|
27
|
+
|
28
|
+
|
29
|
+
ーーーindex.hhtmlーーー
|
30
|
+
|
31
|
+
<form name="form1" action="./x.php" method="POST">
|
32
|
+
|
33
|
+
ページタイトル:<br />
|
34
|
+
|
35
|
+
<input type="text" name="pagetitle" size="70" value=""/><br />
|
36
|
+
|
27
|
-
|
37
|
+
キーワード:<br />
|
38
|
+
|
39
|
+
<input type="text" name="keyword" size="70" value=""/><br />
|
40
|
+
|
41
|
+
ディスクリプション:<br />
|
42
|
+
|
43
|
+
<textarea name="dis" rows="3" cols="70"/></textarea><br />
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
<input type="text" name="gaurl" size="70"value="XXXXXXXXXXXXXXXXXXXXXXX"><br />
|
48
|
+
|
49
|
+
<br />
|
50
|
+
|
51
|
+
サブタイトル:<br />
|
52
|
+
|
53
|
+
<input type="text" name="sabutitle" size="70" value=" "/><br />
|
54
|
+
|
55
|
+
本文<br />
|
56
|
+
|
57
|
+
<textarea name="honbun" rows="6" cols="70" >
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
</textarea><br />
|
62
|
+
|
63
|
+
画像下本文(画像の下にここに記入した文字が入ります)<br />
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
<input type="submit" value="送信" />
|
68
|
+
|
69
|
+
</form>
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
ーーーx.phpーーー
|
78
|
+
|
79
|
+
<?php
|
28
80
|
|
29
81
|
|
30
82
|
|
@@ -32,7 +84,11 @@
|
|
32
84
|
|
33
85
|
$m = date('m');
|
34
86
|
|
87
|
+
|
88
|
+
|
35
|
-
$dirname = '/' . $y . '/' . $m . '/';
|
89
|
+
$dirname = './' . $y . '/' . $m . '/';
|
90
|
+
|
91
|
+
|
36
92
|
|
37
93
|
if (!is_dir($dirname)) {
|
38
94
|
|
@@ -46,7 +102,143 @@
|
|
46
102
|
|
47
103
|
|
48
104
|
|
105
|
+
$template = "temp.php"; // テンプレートファイル名
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
if ($_POST{"honbun"}) {
|
110
|
+
|
111
|
+
// ※1 POSTデータを全て受け取りエスケープして変数に入れる
|
112
|
+
|
113
|
+
foreach($_POST as $k => $v) {
|
114
|
+
|
115
|
+
if(get_magic_quotes_gpc()) { $v=stripslashes($v); }
|
116
|
+
|
117
|
+
// $v=htmlspecialchars($v);
|
118
|
+
|
119
|
+
$array[$k]=$v;
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
extract($array);
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
// 文字コードはUTF-8
|
128
|
+
|
129
|
+
$keyword = mb_convert_encoding($keyword, "UTF-8","AUTO");
|
130
|
+
|
131
|
+
$dis = mb_convert_encoding($dis, "UTF-8","AUTO");
|
132
|
+
|
133
|
+
$gaurl = mb_convert_encoding($gaurl, "UTF-8","AUTO");
|
134
|
+
|
135
|
+
$sabutitle = mb_convert_encoding($sabutitle, "UTF-8","AUTO");
|
136
|
+
|
137
|
+
$honbun = mb_convert_encoding($honbun, "UTF-8","AUTO");
|
138
|
+
|
139
|
+
$honbun1 = mb_convert_encoding($honbun1, "UTF-8","AUTO");
|
140
|
+
|
141
|
+
$pagetitle = mb_convert_encoding( htmlspecialchars($pagetitle), "UTF-8","AUTO");
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
// 改行を<br>タグに変換
|
148
|
+
|
149
|
+
$honbun = nl2br($honbun);
|
150
|
+
|
151
|
+
$honbun1 = nl2br($honbun1);
|
152
|
+
|
153
|
+
$dis = nl2br($dis);
|
154
|
+
|
155
|
+
$keyword = nl2br($keyword);
|
156
|
+
|
157
|
+
$sabutitle = nl2br($sabutitle);
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
// 時間をファイル名に
|
166
|
+
|
49
|
-
|
167
|
+
$filename = date("YmdHis").$_FILES['userfile']['name'] . ".html";
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
// ※2 メッセージ表示
|
172
|
+
|
173
|
+
if (createNewPage( $filename, $template, $pagetitle, $keyword, $dis, $sabutitle, $gaurl, $honbun, $honbun1)) {
|
174
|
+
|
175
|
+
echo '<a href="'.$dirname.$filename.'">http://vba.sstaishou.jp/beta/'.$dirname.$filename.'</a>'."を生成し、書き込みを行いました。";
|
176
|
+
|
177
|
+
} else {
|
178
|
+
|
179
|
+
echo "ファイルの生成に失敗しました。";
|
180
|
+
|
181
|
+
}
|
182
|
+
|
183
|
+
} else {
|
184
|
+
|
185
|
+
echo "フォームから記事の内容を送信してください。";
|
186
|
+
|
187
|
+
}
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
// ※3 ページ生成関数 createNewPage()
|
192
|
+
|
193
|
+
function createNewPage( $filename, $template, $pagetitle, $keyword, $dis, $sabutitle, $gaurl, $honbun, $honbun1 ) {
|
194
|
+
|
195
|
+
// ※4 テンプレートファイルの読み込み
|
196
|
+
|
197
|
+
if ( ($contents = file_get_contents( $template)) == FALSE) { return false; }
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
// タイトルと記事本文を挿入
|
202
|
+
|
203
|
+
$contents = str_replace( "<%PAGETITLE>", $pagetitle, $contents);
|
204
|
+
|
205
|
+
$contents = str_replace( "<%PAGECONTENTS>", $honbun, $contents);
|
206
|
+
|
207
|
+
$contents = str_replace( "<%PAGECONTENTS1>", $honbun1, $contents);
|
208
|
+
|
209
|
+
$contents = str_replace( "<%PAGEKEYWORD>", $keyword, $contents);
|
210
|
+
|
211
|
+
$contents = str_replace( "<%PAGEDIS>", $dis, $contents);
|
212
|
+
|
213
|
+
$contents = str_replace( "<%PAGESABUTITLE>", $sabutitle, $contents);
|
214
|
+
|
215
|
+
$contents = str_replace( "<%PAGEGAURL>", $gaurl, $contents);
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
// ※5 ファイル生成&書き込み
|
222
|
+
|
223
|
+
if ( ($handle = fopen( $dirname . $filename, 'w')) == FALSE) { return false; }
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
fwrite( $handle, $contents);
|
228
|
+
|
229
|
+
fclose( $handle );
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
return true;
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
}
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
?>
|
50
242
|
|
51
243
|
```
|
52
244
|
|