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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
|
<?php
/* ___________________________________________________
Thank you for ASN forum project : asn forum version 2.0 file : lib.php author : asn - script@tourdebali.com ___________________________________________________
*/
/* ******************************************************************************* * Original from PHPMyAdmin 2.3.0 * $Id: grab_globals.lib.php,v 1.7 2002/07/06 22:10:32 loic1 Exp $ * This library grabs the names and values of the variables sent or posted to a * script in the '$HTTP_*_VARS' arrays and sets simple globals variables from * them. It does the same work for the $PHP_SELF variable. * * loic1 - 2001/25/11: use the new globals arrays defined with php 4.1+ **********************************************************************************/
$target_dir = "uploads/";
if (!defined('PMA_GRAB_GLOBALS_INCLUDED')) { define('PMA_GRAB_GLOBALS_INCLUDED', 1);
if (!empty($_GET)) { extract($_GET, EXTR_OVERWRITE); } else if (!empty($HTTP_GET_VARS)) { extract($HTTP_GET_VARS, EXTR_OVERWRITE); } // end if
if (!empty($_POST)) { extract($_POST, EXTR_OVERWRITE); } else if (!empty($HTTP_POST_VARS)) { extract($HTTP_POST_VARS, EXTR_OVERWRITE); } // end if
if (!empty($_FILES)) { while (list($name, $value) = each($_FILES)) { $$name = $value['tmp_name']; } } else if (!empty($HTTP_POST_FILES)) { while (list($name, $value) = each($HTTP_POST_FILES)) { $$name = $value['tmp_name']; } } // end if
if (!empty($_SERVER) && isset($_SERVER['PHP_SELF'])) { $PHP_SELF = $_SERVER['PHP_SELF']; } else if (!empty($HTTP_SERVER_VARS) && isset($HTTP_SERVER_VARS['PHP_SELF'])) { $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF']; } // end if
} // $__PMA_GRAB_GLOBALS_LIB__
/********************************************* * Connect to mysql database *********************************************/
if ($running=="hosting"){ /* for nonedindange hosting */
$conn = mysql_connect($dbhost, $dbuser, $dbpass); if (!$conn) {die('Not connected : ' . mysql_error());} $db_selected = mysql_select_db($db, $conn); if (!$db_selected) { die ('Can\'t use foo : ' . mysql_error()); } mysql_query("SET NAMES UTF8"); /* _ non hosting */ }else{ // localhost // old mysql version include('mydql2i-2017-09-06/mysql2i.class.php'); $conn = new mysqli($dbhost, $dbuser, $dbpass); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } mysql_select_db($db,$conn) or die("Error - Can't open the database !"); }
/********************************************* * Simple email validation *********************************************/ function check_name_reserve($chk){ global $name_reserve; if (strstr($name_reserve,$chk)) erro("<b>\"$chk\"</b><br>ชื่อนี้ สงวนไว้สำหรับผู้ดูแลนะคะ"); } function check_email($email) { if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { erro("Email address <b>$email</b> ไม่ถูกต้อง <br>กรุณากลับไปแก้ไขให้ถูกต้อง.\n"); } //if(!preg_match("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $email)) { // erro("Invalid email address!"); //} }
/********************************************* * Convert smiley code into emoticon *********************************************/
function smile($message) { global $url_smiles; $message = ' ' . $message; if ($getsmiles = mysql_query("SELECT *, length(code) as length FROM mtalk_smile ORDER BY length DESC")) { while ($smiles = mysql_fetch_array($getsmiles)) { $smile_code = preg_quote($smiles['code']); $smile_code = str_replace('/', '//', $smile_code); $message = preg_replace("/([\n\\ \\.])$smile_code/si", '\1<IMG SRC="' . 'images' . '/' . $smiles['smile_url'] . '">', $message); } } $message = substr($message, 1); return($message); }
/****************************************************************************************** * convert url text become clickable * original from PHPBB ******************************************************************************************/
function auto_url($text) { $ret = " " . $text; $ret = preg_replace("#([\n ])([a-z]+?)://([^, \n\r]+)#i", "\\1<a href=\"\\2://\\3\" target=\"_blank\">\\2://\\3</a>", $ret); $ret = preg_replace("#([\n ])www\.([a-z0-9\-]+)\.([a-z0-9\-.\~]+)((?:/[^, \n\r]*)?)#i", "\\1<a href=\"http://www.\\2.\\3\\4\" target=\"_blank\">www.\\2.\\3\\4</a>", $ret); $ret = preg_replace("#([\n ])([a-z0-9\-_.]+?)@([^, \n\r]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret); $ret = substr($ret, 1); return($ret); }
/****************************************************************************************** * Generate paging navigation. * Original from PHPBB with some modifications to make them more simple ******************************************************************************************/
function generate_pagination($base_url, $num_items, $per_page, $start_item, $add_prevnext_text = TRUE) { $total_pages = ceil($num_items/$per_page); if ( $total_pages == 1 ) { return ""; } $on_page = floor($start_item / $per_page) + 1; $page_string = ""; if ( $total_pages > 10 ) { $init_page_max = ( $total_pages > 3 ) ? 3 : $total_pages; for($i = 1; $i < $init_page_max + 1; $i++) { $page_string .= ( $i == $on_page ) ? "<b>" . $i . "</b>" : "<a href=\"$base_url&start=" . ( ( $i - 1 ) * $per_page ) . "\">" . $i . "</a>"; if ( $i < $init_page_max ) { $page_string .= ", "; } } if ( $total_pages > 3 ) { if ( $on_page > 1 && $on_page < $total_pages ) { $page_string .= ( $on_page > 5 ) ? " ... " : ", "; $init_page_min = ( $on_page > 4 ) ? $on_page : 5; $init_page_max = ( $on_page < $total_pages - 4 ) ? $on_page : $total_pages - 4;
for($i = $init_page_min - 1; $i < $init_page_max + 2; $i++) { $page_string .= ($i == $on_page) ? "<b>" . $i . "</b>" : "<a href=\"$base_url&start=" . ( ( $i - 1 ) * $per_page ) . "\">" . $i . "</a>"; if ( $i < $init_page_max + 1 ) { $page_string .= ", "; } } $page_string .= ( $on_page < $total_pages - 4 ) ? " ... " : ", "; } else { $page_string .= " ... "; } for($i = $total_pages - 2; $i < $total_pages + 1; $i++) { $page_string .= ( $i == $on_page ) ? "<b>" . $i . "</b>" : "<a href=\"$base_url&start=" . ( ( $i - 1 ) * $per_page ) . "\">" . $i . "</a>"; if( $i < $total_pages ) { $page_string .= ", "; } } } } else { for($i = 1; $i < $total_pages + 1; $i++) { $page_string .= ( $i == $on_page ) ? "<b>" . $i . "</b>" : "<a href=\"$base_url&start=" . ( ( $i - 1 ) * $per_page ) . "\">" . $i . "</a>"; if ( $i < $total_pages ) { $page_string .= ", "; } } } if ( $add_prevnext_text ) { if ( $on_page > 1 ) { $page_string = " <a href=\"$base_url&start=" . ( ( $on_page - 2 ) * $per_page ) . "\">« ก่อนหน้า</a> " . $page_string; }
if ( $on_page < $total_pages ) { $page_string .= " <a href=\"$base_url&start=" . ( $on_page * $per_page ) . "\">ถัดไป »</a>"; } }
$page_string = "หน้าที่ : " . $page_string; return $page_string; }
/********************************************* * Error and Message handling * Not so cool coding, but IT WORKS! *********************************************/
function erro($message) { global $tipe, $forum_name, $forum_title;
include("header.php");
if ($tipe == 'no') $title = "MESSAGE : คำแนะนำ "; else $title = "ERROR : ผิดพลาด !"; echo "<center><p></p><br>\n <table width=\"400\" border=\"0\" cellspacing=\"0\" cellpadding=\"10\" class=\"replyform\" bgcolor=\"#f0f0f0\"> <tr> <td align=\"center\" class=\"normal\"><font size=\"3\" color=\"#CC0000\"><b>$title</b></font><br><br> $message </td> </tr> </table> <br> <br> <table width=\"400\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td> <table border=\"0\" cellspacing=\"0\" cellpadding=\"1\" bgcolor=\"#CCCCCC\" width=\"200\"> <tr> <td> <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\" bgcolor=\"#f5f5f5\"> <tr> <td class=\"normal\" align=\"center\"><b> <a href=\"javascript:history.back();\" class=\"none\">กลับไปแก้ไข</a> </b></td> </tr> </table> </td> </tr> </table> </td> <td><img src=\"images/space.gif\" width=\"5\" height=\"10\"></td> <td> <table border=\"0\" cellspacing=\"0\" cellpadding=\"1\" bgcolor=\"#CCCCCC\" width=\"200\"> <tr> <td> <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\" bgcolor=\"#f5f5f5\"> <tr> <td class=\"normal\" align=\"center\"><b> <a href=\"index.php\" class=\"none\">กลับหน้าหลักหลัก</a> </b></td> </tr> </table> </td> </tr> </table> </td> </tr> </table><br><br><br></center>"; include("footer.php"); die(); }
function makebutton($xtext, $xlink, $xwidth) { echo" <table border=\"0\" cellspacing=\"0\" cellpadding=\"1\" bgcolor=\"#CCCCCC\" width=\"$xwidth\"> <tr> <td> <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\" bgcolor=\"#f5f5f5\"> <tr> <td class=\"normal\" align=\"center\"><b> <a href=\"$xlink\" class=\"none\">$xtext</a> </b></td> </tr> </table> </td> </tr> </table>"; }
$b2smiliestrans = array( ':-?' => 'icon_confused.gif', '8)' => 'icon_cool.gif', ':cry:' => 'icon_cry.gif', ':oops:' => 'icon_redface.gif', ':evil:' => 'icon_evil.gif', ':))' => 'icon_lol.gif', ':x' => 'icon_mad.gif', ':p' => 'icon_razz.gif', ':roll:' => 'icon_rolleyes.gif', ':(' => 'icon_frown.gif', ':)' => 'icon_smile.gif', ':o' => 'icon_eek.gif', ':D' => 'icon_biggrin.gif', ':wink:' => 'icon_wink.gif' );
# sorts the smilies' array if (!function_exists('smiliescmp')) { function smiliescmp ($a, $b) { if (strlen($a) == strlen($b)) { return strcmp($a, $b); } return (strlen($a) > strlen($b)) ? -1 : 1; } } uksort($b2smiliestrans, 'smiliescmp');
# generates smilies' search & replace arrays foreach($b2smiliestrans as $smiley => $img) { $b2_smiliessearch[] = $smiley; $smiley_masked = ''; for ($i = 0; $i < strlen($smiley); $i = $i + 1) { $smiley_masked .= substr($smiley, $i, 1).chr(160); } $b2_smiliesreplace[] = "<img src='images/$img' alt='$smiley_masked' />"; }
function convert_smilies($content) { global $smilies_directory, $use_smilies; global $b2_smiliessearch, $b2_smiliesreplace; if ($use_smilies) { $content = str_replace($b2_smiliessearch, $b2_smiliesreplace, $content); } return ($content); } ?>
|