001.
<? ob_start(); ?>
002.
<?
include
"include/config.php"
;?>
003.
<?
include
"include/function.php"
;?>
005.
<html>
006.
<head>
007.
<meta http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
/>
008.
<link rel=
"stylesheet"
type=
"text/css"
href=
"style.css"
/>
009.
<title>WEBboard</title>
010.
</head>
011.
<?php
012.
$sql
=
"select * from question where id_ques='$_GET[id_ques]'"
;
013.
$query
=mysql_query(
$sql
);
014.
$rsq
=mysql_fetch_array(
$query
);
015.
016.
017.
if
(
$_COOKIE
[
"viewboard"
]!=
"abcd"
){
018.
019.
$sql1
=
"UPDATE question SET view_ques=view_ques+1 WHERE id_ques='$_GET[id_ques]'"
;
020.
$query1
=mysql_query(
$sql1
);
021.
022.
023.
024.
echo
$sql1
;
025.
setcookie(
"viewboard"
,
"abcd"
, time()+30);
026.
}
else
{}
027.
?>
028.
029.
030.
031.
032.
<?
033.
if
(
$_POST
[
'send'
] ==
'ok'
) {
034.
$_detail_aus
=autolink(
$_POST
[
'detail_aus'
]);
035.
if
(
$_POST
[
'detail_aus'
]==
""
)
036.
{
037.
$msn
=
"กรุณาพิมพ์รายละเอียดคำตอบด้วย"
;
038.
}
elseif
(
$_POST
[
'name_ans'
]==
""
){
039.
$msn
=
"กรุณาพิมพ์ชื่อผู้ตอบด้วย"
;
040.
}
041.
else
042.
{
043.
if
(
$_FILES
[
'img_aus'
][
'name'
] !=
""
)
044.
{
045.
$path
=
"img_webboard"
;
046.
if
(!
is_dir
(
$path
)){
047.
mkdir
(
$path
,0777) ; }
048.
$Upload_name
=
$_FILES
[
'img_aus'
][
'name'
];
049.
$Upload_Type
=
$_FILES
[
'img_aus'
][
'type'
];
050.
if
((
$Upload_Type
==
"image/gif"
)
051.
|| (
$Upload_Type
==
"image/pjpeg"
) || (
$Upload_Type
==
"image/jpeg"
)
052.
&& (
$_FILES
[
"img_aus"
][
"size"
] < 50000))
053.
{
054.
$Path_Upload_server
=
$_FILES
[
'img_aus'
][
'tmp_name'
];
055.
$rand
= rand(1111,9999);
056.
$new_name
=
$rand
.
$Upload_name
;
057.
$name_img_aus
=
"$path/$new_name"
;
058.
copy
(
"$Path_Upload_server"
,
"$name_img_aus"
);
059.
$sql
="INSERT INTO answer (name_ans,detail_aus,id_ques,time_aus,img_aus)
060.
VALUES(
'$_POST[name_ans]'
,
'".nl2br($_detail_aus)."'
,
'$_GET[id_ques]'
,now(),
'$name_img_aus'
)";
061.
$query
=mysql_query(
$sql
);
062.
if
(!
$query
)
063.
{
064.
die
(
'Error: '
. mysql_error());
065.
}
066.
067.
068.
$ok
=
"ok"
;
069.
$msnok
=
"<font color=#000>กรุณารอสักครู่....</font>"
; ;
070.
echo
"<META HTTP-EQUIV=Refresh Content=0;URL='view_ques.php?id_ques=$_GET[id_ques]'>"
;
071.
072.
073.
}
074.
else
075.
{
076.
077.
$msn
=
"ไฟล์ไม่ถูกต้อง หรือ ขนาดไฟลืรูปเกิน 50k"
;
078.
}
079.
080.
}
081.
else
{
082.
$sql
=
"INSERT INTO answer (name_ans,detail_aus,time_aus,id_ques)values('$_POST[name_ans]','"
.
nl2br
(
$_detail_aus
).
"',now(),'$_GET[id_ques]')"
;
083.
$query
=mysql_query(
$sql
);
084.
if
(!
$query
)
085.
{
086.
die
(
'Error: '
. mysql_error());
087.
}
088.
089.
090.
091.
092.
093.
echo
"<META HTTP-EQUIV=Refresh Content=0;URL='view_ques.php?id_ques=$_GET[id_ques]'>"
;
094.
}
095.
}
096.
}
097.
?>
098.
<body>
099.
<!--ส่วนพื้นที่ทั้ง หมดของเว็บ -->
100.
<div id=
"allbody"
>
101.
<div id=
"inallbody"
>
102.
<!--ส่วนบนเว็บ haeder -->
103.
<?
include
"include/haeder.php"
;?>
104.
<div id=
"content"
>
105.
106.
<?
107.
108.
if
(
$msn
!=
""
){?>
109.
110.
<center><span style=
"color:red; font-size=15px;"
> <?=
$msn
?>
111.
</span></center>
112.
113.
<?
114.
}
115.
else
116.
{
117.
?>
118.
<table>
119.
<tr>
120.
<th > เรื่อง
121.
122.
<?=
$rsq
[
'name_ques'
]?>
123.
</th>
124.
</tr>
125.
<tr>
126.
<td
class
=
"datapost"
>
127.
<div style=
"display:block; border:0px solid #09C;word-wrap:break-word; "
>
128.
<?php
if
(
is_file
(
$rsq
[
'img_ques'
])){ ?>
129.
<img src=
"<?=$rsq['img_ques'] ?>"
width=
"150"
height=
"120"
>
130.
<?php }
else
{ }?>
131.
132.
133.
<p><?=
$rsq
[
'detail_ques'
] ?> </p>
134.
</div>
135.
</td>
136.
</tr>
137.
<tr>
138.
<td
class
=
"bule"
> ผู้ตั้งคำถาม
139.
<?=
$rsq
[
'name'
] ?>
140.
เวลา
141.
<?=
$rsq
[
'time_ques'
] ?> ip <?=
substr
(
$rsq
[
'ip_ques'
],0,
strrpos
(
$rsq
[
'ip_ques'
],
"."
)).
".xxx"
; ?> viwe <?=
$rsq
[
'view_ques'
]?></td>
142.
</tr>
143.
144.
</table>
145.
146.
147.
148.
149.
150.
<?
151.
152.
153.
$sql
=
"SELECT * FROM answer WHERE id_ques='$_GET[id_ques]' ORDER BY id_ans DESC "
;
154.
$query
=mysql_query(
$sql
);
155.
$numrow
=mysql_num_rows(
$query
);
156.
?>
157.
158.
159.
160.
<?
if
(
$numrow
!=0){ ?>
161.
<p>All Comments:<?=
$numrow
?> Pages:</p>
162.
163.
164.
165.
<?
$i
=1;
166.
while
(
$rs
=mysql_fetch_array(
$query
)){?>
167.
<?
168.
if
(
$i
%2==1){
169.
$calss
=
""
;
170.
}
else
{
171.
$calss
=
"bule"
;
172.
}
173.
174.
175.
<hr/>
176.
177.
<table style=
"border:0; "
>
178.
<tr style=
" background:#ff8040;"
>
179.
<td width=
"819"
>เรื่อง
180.
<?=
$rsq
[
'name_ques'
] ?></td>
181.
<td width=
"69"
>
182.
<?
if
(
$_SESSION
[
'admin'
]!=
'admin'
){
183.
?>
184.
แจ้งลบ
185.
<?
186.
}
else
{
187.
?>
188.
ลบ
189.
<?
190.
}
191.
?>
192.
</td>
193.
</tr>
194.
<tr>
195.
<td colspan=
"2"
>
196.
<div
class
=
"posta"
>
197.
<?php
if
(
is_file
(
$rs
[
'img_aus'
])){ ?>
198.
<img src=
"<?=$rs['img_aus'] ?>"
width=
"150"
height=
"120"
>
199.
<?php }
else
{ }?>
200.
201.
202.
<p><?=
$rs
[
'detail_aus'
] ?> </p>
203.
</div></td>
204.
</tr>
205.
<tr>
206.
<td colspan=
"2"
style=
" background:#ffd5bf;"
>ผู้ตอบ
207.
<?=
$rs
[
'name_ans'
].
" "
?>
208.
เวลา
209.
<?=
$rs
[
'time_aus'
] ?></td>
210.
</tr>
211.
</table>
212.
213.
<? }?>
214.
215.
<? }
else
{
216.
217.
218.
}}
219.
220.
221.
222.
223.
224.
?>
225.
<hr/>
226.
227.
<form action=
""
method=
"post"
enctype=
"multipart/form-data"
name=
"myform"
>
228.
<table style=
"width:300px; "
>
229.
230.
<tr>
231.
<td colspan=
"2"
class
=
"bule"
>
232.
<textarea name=
"detail_aus"
id=
"detail_aus"
cols=
"120"
rows=
"10"
style=
"overflow:hidden; "
><?=
nl2br
(
$_POST
[detail_aus])?></textarea></td>
233.
</tr>
234.
<tr>
235.
<td colspan=
"2"
class
=
"bule"
>
236.
<table style=
"border:0px; width:700px; "
>
237.
<tr>
238.
<td width=
"121"
>รูปประกอบ </td>
239.
<td width=
"761"
><input type=
"file"
name=
"img_aus"
id=
"fileField"
></td>
240.
</tr>
241.
<tr>
242.
<td>ชื่อผู้ตอบ </td>
243.
<td><input type=
"text"
name=
"name_ans"
id=
"textfield"
value=
"<?=$_POST[name_ans]?>"
></td>
244.
</tr>
245.
</table></td>
246.
</tr>
247.
<tr>
248.
<td
class
=
"bule"
>
249.
<input name=
"send"
type=
"hidden"
id=
"send"
value=
"ok"
></td>
250.
<td
class
=
"bule"
><input type=
"submit"
name=
"button"
id=
"button"
value=
"Submit"
> <input type=
"reset"
name=
"button2"
id=
"button2"
value=
"Reset"
></td>
251.
</tr>
252.
</table>
253.
</form>
254.
255.
</div>
256.
<?
include
"include/footter.php"
;?>
257.
258.
</div>
259.
</div>
260.
</body>
261.
</html>
262.
263.
<? ob_end_flush()?>