1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
<?php include("config.php"); include("lib.php"); ?> <?php
$IP = $_POST["verify"]; $pecah = explode(".",$REMOTE_ADDR); $pecah3 = $pecah[0] . $pecah[1] . $pecah[2] . session_id();
echo $_SESSION['num_to_check'][0]."+".$_SESSION['num_to_check'][1]; if ($IP != md5($floodpass.$pecah3)) { exit(); } if($_SESSION['num_to_check'][0]+$_SESSION['num_to_check'][1] != $_POST["vcaptcha"]){ erro("คุณบวกเลขผิด"); } $_SESSION['tdata']['nama']=$nama; $_SESSION['tdata']['email']=$email; $_SESSION['tdata']['homepage']=$homepage; $_SESSION['tdata']['topictext']=$topictext; //if (trim($nama)=="" or trim($email=="") or trim($topictext)=="") { if (trim($nama)=="" or trim($topictext)=="") { erro("ยังใส่ข้อมูลไม่ครบทุกช่อง โดยเฉพาะช่องที่มีเครื่องหมาย <font color=red><b>*</b></font> จำเป็นต้องใส่"); }
check_name_reserve(trim($nama)); if (trim($homepage)=="http://") $homepage = ""; if ($email) check_email($email);
$nama = htmlspecialchars($nama); $email = htmlspecialchars($email); $homepage = htmlspecialchars($homepage);
$test_comment = explode(" ",$topictext); $jmltest = count($test_comment);
for ($t=0; $t<$jmltest; $t++) { if (strlen(trim($test_comment[$t])) > 1000) { erro("จำนวนตัวหนังสือห้ามติดกันเกิน 1000 ตัวอักษร"); } }
// check image if (! empty($_FILES['attachment'])) { $count = count($_FILES['attachment']['name']); if ($count > 0) { for ($i = 0; $i < $count; $i ++) { if (! empty($_FILES["attachment"]["name"])) { $uploadOk = 1; $TempFile = $_FILES["attachment"]["tmp_name"][$i]; $TempfileName = $_FILES["attachment"]["name"][$i]; $imageFileType = strtolower(pathinfo($TempfileName,PATHINFO_EXTENSION)); if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" ) { echo "ขออภัย, $TempfileName ไม่ใช่รูปภาพ, อนุญาติให้แนบไฟล์รูปภาพ (JPG, JPEG, PNG & GIF) เท่านั้น."; $uploadOk = 0; } } } } } // end check image
$Chk = 0; // echo "$topictext<br>"; // echo $count1 = count(explode("http:", $topictext)); // echo $count2 = count(explode("http:", $nama)); if (strstr($topictext,"http")) $SPAM=1; if (strstr($nama,"http")) $SPAM=1; if ($SPAM) { echo "<p>ไม่สามารถบันทึกได้ เนื่องจากระบบตรวจพบว่าท่านกำลัง SPAM ข้อความ, ระบบไม่อนุญาติให้ใส่ html ในข้อความ</p>"; echo "<br><br> <a href='viewtopic.php?id=$id'>คลิกที่นี่เพื่อกลับไปยังข้อความ</a>"; }else{
$topictext = htmlspecialchars($topictext); $topictext = str_replace("\n","<BR>",$topictext); $tgl = date("Y-m-d H:i"); $ins1 = mysql_query("INSERT INTO mtalk_post VALUES(null, '$id', '$nama', '$tgl', '$email','')"); $this_post = mysql_insert_id(); $ins2 = mysql_query("INSERT INTO mtalk_postext VALUES($this_post, '$topictext','$attached')"); $ins2 = mysql_query("UPDATE mtalk_topic SET topic_replies=topic_replies+1, topic_last_post_id='$this_post' WHERE topic_id=$id"); // Work with image upload if (! empty($_FILES['attachment'])) { $count = count($_FILES['attachment']['name']); if ($count > 0) { for ($i = 0; $i < $count; $i ++) { if (! empty($_FILES["attachment"]["name"])) { // Allow certain file formats $uploadOk = 1; $TempFile = $_FILES["attachment"]["tmp_name"][$i]; $TempfileName = $_FILES["attachment"]["name"][$i]; $imageFileType = strtolower(pathinfo($TempfileName,PATHINFO_EXTENSION)); /* if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" ) { echo "Sorry, $TempfileName not image file, Please upload only JPG, JPEG, PNG & GIF files."; $uploadOk = 0; } */ $NfileName="$this_post-$i-".basename($TempfileName); $SaveFile = $target_dir.$NfileName; if (move_uploaded_file($TempFile, $SaveFile)) { echo "The file $fileName has been uploaded and change file name to $NfileName"; $fileAttached=$fileAttached."/".$NfileName; mysql_query("UPDATE mtalk_postext SET attached='$fileAttached' WHERE post_id = $this_post"); }else{ echo "Sorry, there was an error uploading your file."; } } } } } //end Work with image upload
$url = "Location: viewtopic.php?id=$id"; unset($_SESSION['tdata']); header($url); } ?>
|