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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
<?php // Status Package Module $status_module=select_query("status_module","cms_status_module","id","18"); if($status_module[0]!=1) { fieldset_no_module(); } // Pession if(id_top_permission("b")!=1){ permission_fail(); } $navig['gallery']="ภาพกิจกรรม"; $navig['gallery_add']="เพิ่มภาพกิจกรรม"; navigator($navig); echo "<br>"; bar_header("เพิ่มภาพกิจกรรม"); fieldset_top("ภาพกิจกรรม");
include_once("coremain/module/gallery/class.upload.php"); import_request_variables('pG', 'p_'); if($p_fulltexts!="") { $fulltexts=trim($p_fulltexts); } if($p_en_fulltexts!="") { $en_fulltexts=trim($p_en_fulltexts); } if($p_add_topic!="") { $add_topic=trim($p_add_topic); } if($p_block!="") { $block=trim($p_block); } if($p_id_topic!="") { $id_topic=trim($p_id_topic); } if($p_upload_pic_ok!="") { $upload_pic_ok=trim($p_upload_pic_ok); } if($p_upload_pic!="") { $upload_pic=trim($p_upload_pic); } if($p_explain!="") { $explain=trim($p_explain); } if($p_en_explain!="") { $en_explain=trim($p_en_explain); } if($p_check_upload!="") { $check_upload=trim($p_check_upload); }
if($add_topic=="1"){ //*******เพิ่มข้อมูลลงในฐาน************************************************* // หาค่า id สูงสุด + 1 $sqlmax1="select max(id_topic+1) from port_gallery_topic"; $resultmax1=mysql_query($sqlmax1); $datamax1=mysql_fetch_row($resultmax1); if ($datamax1[0]=="") { $datamax1[0]="1"; } $port_id=$_SESSION[port][id]; $sql = "INSERT INTO port_gallery_topic(id_topic,port_id,fulltexts,en_fulltexts,block,status) values('$datamax1[0]','$port_id','$fulltexts','$en_fulltexts','$block','1')"; $result = mysql_query($sql) or die(mysql_error()); echo "<center><br><br>ชื่อกิจกรรมได้ถูกบันทึกแล้ว<br><br>ขั้นตอนต่อไปให้เลือกรูปที่จะ Upload </center>"; echo "<meta http-equiv='refresh' content='2; url=index.php?mod=gallery_output&path=gallery&id_topic=$datamax1[0]&link1=$link1'>" ; }
// #################Upload Picture##################### $userfile1_name=trim($_FILES['userfile1']['name']);
if($userfile1_name!="" and $id_topic!=""){ $strings1=substr($userfile1_name,-4); if($strings1!=".gif" and $strings1!=".jpg" and $strings1!=".GIF" and $strings1!=".JPG"){ echo"<center><br>ชนิดไฟล์ไม่ถูกต้อง <br>ไฟล์ต้องมีนามสกุลเป็น .gif หรือ .jpg เท่านั้น<br><br>"; echo"<a href='javascript:history.back()'><font color='ff0000'>[แก้ไขใหม่]</font></center></a>"; exit; } }
//************** ตรวจสอบว่า มีการ Upload File ที่ 1 หรือไม************่ //einstein2
include_once("coremain/module/gallery/myfunction.php"); $filenow = $_FILES['userfile1']['size'];
if(1){ if($userfile1_name!="" and $id_topic!="") { // กำหนดชื่อไฟล์ที่ upload ใหม่ ทั้งนี้เพื่อให้ ไฟล์ไม่ซ้ำกัน $str = "123456789abcdefghijkmnpqrstuvwxyz"; $pic1 = substr(str_shuffle($str), 0, 9); $strings=substr($userfile1_name,-4); $strings = strtolower($strings); $name1="pic$pic1$strings"; $dlink="$_SESSION[web_name]/".$name1; /* $temp_name=$_FILES['userfile1']['tmp_name']; if (is_uploaded_file($_FILES['userfile1']['tmp_name'])) { if(!move_uploaded_file($temp_name,$dlink)){ } }*/ $hup = new upload($_FILES['userfile1']); if($hup->uploaded){ $hup->image_resize = true; $hup->image_y = 400; $hup->image_x = 640; $hup->image_ratio = true; $hup->jpeg_quality = 95; $hup->image_ratio_no_zoom_in = true; $hup->file_new_name_body = "pic{$pic1}"; $hup->Process("$_SESSION[web_name]/gallery/"); if($hup->processed){
}else{ //echo 'failed'; } $hup->image_resize = true; $hup->image_y = 100; $hup->image_x = 150; $hup->image_ratio = true; $hup->jpeg_quality = 95; $hup->image_ratio_no_zoom_in = true; $hup->file_new_name_body = "pic{$pic1}"; $hup->Process("$_SESSION[web_name]/gallery/thumb/"); if($hup->processed){ //echo 'success2'; chmod("$_SESSION[web_name]/gallery/thumb/{$name1}",0777); }else{ echo 'failed'; } } }
// ########### Add ข้อมูลลงใน Record ############ if($id_topic!="" and $userfile1_name!=""){ // หาค่า id สูงสุด + 1 $sqlmax1="select max(id_record+1) from port_gallery_record"; $resultmax1=mysql_query($sqlmax1); $datamax1=mysql_fetch_row($resultmax1); if ($datamax1[0]=="") { $datamax1[0]="1"; }
$sql = "INSERT INTO port_gallery_record values('$datamax1[0]','$id_topic','$name1','$explain','$en_explain','1')"; $result = mysql_query($sql) or die(mysql_error()); if($upload_pic!=""){ echo "<center><br><br>รูปได้ถูกเพิ่มแล้ว<br><br></center>"; echo "<meta http-equiv='refresh' content='2; url=index.php?mod=gallery_output&path=gallery&id_topic=$id_topic'>" ;
}else if($upload_pic_ok!=""){ echo "<center><br><br>กระบวนการได้เสร็จสมบูรณ์แล้ว<br><br></center>"; echo "<meta http-equiv='refresh' content='2; url=index.php?mod=gallery&path=gallery'>" ;
} }
}else{ echo '<center>'; echo '<font color="red">'; echo '<h3>ไม่สามารถ upload ไฟล์ได้!</h3>'; echo 'ไฟล์ที่ท่าน upload อยู่นี้มีขนาดไฟล์ '.number_format(($filenow/1048576),2).' MB<br/>'; echo 'ซึ่งเกินพื้นที่จัดเก็บของท่าน'; echo '</font>'; echo '<p>'; echo '<button onClick="javascript:window.history.go(-1)">เลือก upload ใหม่</button>'; echo '</p>'; echo '<center>'; } //end
if($id_topic!="" and $check_upload==""){ echo"<form action='index.php?mod=gallery_output&path=gallery&id_topic=$id_topic' method='post' enctype='multipart/form-data' name='add' id='add' onSubmit='return checkadd()'>"; echo"<table width='98%' border='0' align='center' cellpadding='1' cellspacing='1'>"; echo" <tr>"; echo" <td colspan='2' align=center><b>สามารถ Upload รูปได้ครั้งละ 1 รูป พร้อมคำอธิบาย<br>โดย Upload รูปได้ไม่จำกัดจำนวน</b><br><br></td> "; echo" </tr>";
echo" <tr>"; echo" <td width='30%' align=center><img src='coremain/images/marker.gif'> <strong>Upload รูป</strong></td> "; echo" <td><input name='userfile1' type='file' size='40'> <img src='coremain/images/bu.gif' border='0' title='รูปควรมีขนาดประมาณ 400*300 Pixel' onmouseover=this.style.cursor='hand'>"; echo" </td> "; echo" </tr>";
echo" <tr>"; echo" <td align=center><img src='coremain/images/marker.gif'> <strong> คำอธิบายรูป </strong></td> "; echo" <td><input name='explain' type='text' size='40' >"; echo "<INPUT TYPE='hidden' name='check_upload' value='1'>"; echo" </td> "; echo" </tr>";
echo"<tr> "; echo" <td colspan=2 align=center><br> "; echo"<input type='submit' name='upload_pic' value='Upload อื่นรูปต่อ' onmouseover=this.style.cursor='hand'> "; echo"<input type='submit' name='upload_pic_ok' value='Upload รูปเรียบร้อย' onmouseover=this.style.cursor='hand'> "; echo"</td>"; echo" </tr>";
echo "</table>"; echo "</form>"; } fieldset_down(); ?> <script language="javascript"> function checkadd() { if(document.add.userfile1.value=="") { alert("กรุณาเลือกรูปที่จะอัพโหลด") ; document.add.userfile1.focus() ; return false ;} else return true ; } </script>
|