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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
|
<?php $country_list_en = array(1=> "Asia/Pacific Region","Europe","Andorra","United Arab Emirates","Afghanistan","Antigua and Barbuda","Anguilla","Albania","Armenia","Curcao", "Angola","Antarctica","Argentina","American Samoa","Austria","Australia","Aruba","Azerbaijan","Bosnia and Herzegovina","Barbados", "Bangladesh","Belgium","Burkina Faso","Bulgaria","Bahrain","Burundi","Benin","Bermuda","Brunei Darussalam","Bolivia", "Brazil","Bahamas","Bhutan","Bouvet Island","Botswana","Belarus","Belize","Canada","Cocos (Keeling) Islands","Congo, The Democratic Republic of the", "Central African Republic","Congo","Switzerland","Cote D'Ivoire","Cook Islands","Chile","Cameroon","China","Colombia","Costa Rica", "Cuba","Cape Verde","Christmas Island","Cyprus","Czech Republic","Germany","Djibouti","Denmark","Dominica","Dominican Republic", "Algeria","Ecuador","Estonia","Egypt","Western Sahara","Eritrea","Spain","Ethiopia","Finland","Fiji", "Falkland Islands (Malvinas)","Micronesia, Federated States of","Faroe Islands","France","Sint Maarten (Dutch part)","Gabon","United Kingdom","Grenada","Georgia","French Guiana", "Ghana","Gibraltar","Greenland","Gambia","Guinea","Guadeloupe","Equatorial Guinea","Greece","South Georgia and the South Sandwich Islands","Guatemala", "Guam","Guinea-Bissau","Guyana","Hong Kong","Heard Island and McDonald Islands","Honduras","Croatia","Haiti","Hungary","Indonesia", "Ireland","Israel","India","British Indian Ocean Territory","Iraq","Iran, Islamic Republic of","Iceland","Italy","Jamaica","Jordan", "Japan","Kenya","Kyrgyzstan","Cambodia","Kiribati","Comoros","Saint Kitts and Nevis","Korea, Democratic People's Republic of","Korea, Republic of","Kuwait", "Cayman Islands","Kazakhstan","Lao People's Democratic Republic","Lebanon","Saint Lucia","Liechtenstein","Sri Lanka","Liberia","Lesotho","Lithuania", "Luxembourg","Latvia","Libya","Morocco","Monaco","Moldova, Republic of","Madagascar","Marshall Islands","Macedonia","Mali", "Myanmar","Mongolia","Macau","Northern Mariana Islands","Martinique","Mauritania","Montserrat","Malta","Mauritius","Maldives", "Malawi","Mexico","Malaysia","Mozambique","Namibia","New Caledonia","Niger","Norfolk Island","Nigeria","Nicaragua", "Netherlands","Norway","Nepal","Nauru","Niue","New Zealand","Oman","Panama","Peru","French Polynesia", "Papua New Guinea","Philippines","Pakistan","Poland","Saint Pierre and Miquelon","Pitcairn Islands","Puerto Rico","Palestinian Territory","Portugal","Palau", "Paraguay","Qatar","Reunion","Romania","Russian Federation","Rwanda","Saudi Arabia","Solomon Islands","Seychelles","Sudan", "Sweden","Singapore","Saint Helena","Slovenia","Svalbard and Jan Mayen","Slovakia","Sierra Leone","San Marino","Senegal","Somalia","Suriname", "Sao Tome and Principe","El Salvador","Syrian Arab Republic","Swaziland","Turks and Caicos Islands","Chad","French Southern Territories","Togo","Thailand", "Tajikistan","Tokelau","Turkmenistan","Tunisia","Tonga","Timor-Leste","Turkey","Trinidad and Tobago","Tuvalu","Taiwan", "Tanzania, United Republic of","Ukraine","Uganda","United States Minor Outlying Islands","United States","Uruguay","Uzbekistan","Holy See (Vatican City State)","Saint Vincent and the Grenadines","Venezuela", "Virgin Islands, British","Virgin Islands, U.S.","Vietnam","Vanuatu","Wallis and Futuna","Samoa","Yemen","Mayotte","Serbia","South Africa", "Zambia","Montenegro","Zimbabwe","Anonymous Proxy","Satellite Provider","Other","Aland Islands","Guernsey","Isle of Man","Jersey", "Saint Barthelemy","Saint Martin", "Bonaire, Saint Eustatius and Saba" ); function sendEmail( $to, $subject, $content_arr = array(), $sender_name, $sender_email, $map_file ,$form_name) { $headers = "From: ".$sender_name." <".$sender_email.">\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=uft-8\r\n"; $headers .= "Reply-To: ".$sender_name."<".$sender_email.">\r\n"; $headers .= "Return-Path: ".$sender_name."<".$sender_email.">\r\n"; $headers .= "Message-ID: <".time()." ".$sender_email.">\r\n"; $headers .= "X-Mailer: PHP v".phpversion()."\r\n"; $msg = file_get_contents( '../../../email/' . $map_file ); $msg = str_replace('{sender_email}', $sender_email, $msg); foreach ( $content_arr as $key=>$value ){ $msg = str_replace('{'.$key.'}', $value, $msg); } include('../../../email/class.phpmailer.php'); $x_mail = new PHPMailer(); $x_mail->IsSMTP(); //$x_mail->SMTPDebug = 2; $x_mail->Host = 'smtp.mandrillapp.com'; // Specify main and backup server $x_mail->Port = 587; // Set the SMTP port $x_mail->SMTPAuth = true; // Enable SMTP authentication $x_mail->Username = 'garricklam@onesolution.com.hk'; // SMTP username $x_mail->Password = 'lYtE-w6jVOD4vZQrurvraQ'; // SMTP password $x_mail->SMTPSecure = 'tls';
$x_mail->CharSet = "UTF-8"; $x_mail->Sender = $to; //$x_mail->AddReplyTo($enquiryemail, $company_name); $x_mail->From = $sender_email; $x_mail->FromName = $sender_name;
$x_mail->AddAddress($to, $form_name); //$x_mail->AddBCC("kelvinchan@onesolution.com.hk", $company_name);
$x_mail->WordWrap = 50; $x_mail->IsHTML(true); $x_mail->Subject = $subject; $x_mail->Body = $msg;
$x_mail->Send(); //echo $msg; //return mail($to, $subject, $msg, $headers); } if (!function_exists('random_string')) { function random_string($length = 8) { $chars = "abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ23456789abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ23456789"; $random_string = substr(str_shuffle($chars), 0, $length); return $random_string; } }
if (!function_exists('last_url')) { function last_url() { $protocol = strpos(strtolower($_SERVER['SERVER_PROTOCOL']), 'https') === false ? 'http' : 'https'; $host = $_SERVER['HTTP_HOST']; /*$script = $_SERVER['SCRIPT_NAME']; $params = $_SERVER['QUERY_STRING'];*/
//$lastUrl = $protocol . '://' . $host . $script . '?' . $params;
$path = $_SERVER['REQUEST_URI']; $lastUrl = $protocol . '://' . $host . $path;
return $lastUrl; }
}
if (!function_exists('rsa_crypt')) { function rsa_crypt($data, $encrypt_decrypt) {
/*set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib0.3.8'); include('Net/SSH2.php'); include('Crypt/RSA.php');*/
set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib0.3.8');
if (!class_exists('Crypt_RSA')) { include('phpseclib0.3.8/Crypt/RSA.php'); }
if (!class_exists('Net_SSH2')) { include('phpseclib0.3.8/Net/SSH2.php'); }
if ($encrypt_decrypt == 1) { $rsa_encrypt = new Crypt_RSA();
$public_key = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDcttCaGylMIBfe4rsAragQpXj5 UuE8exmFrUTcracHRuCs552hrdvAS2WiOe8fSeZuPkGfo1NBu/d+EhbJEc0lS3JK x1V0wpSyeiNdlvzG4Wh5hVi00n4WjCDwq2bfzurXuJrm/dbjxQ7acJ4HWRNGHrPV 7EfGi2AA4QBvl+j3MQIDAQAB ";
$rsa_encrypt->loadKey($public_key); // public key
if (!empty($data)) { return base64_encode($rsa_encrypt->encrypt($data)); } else { return ""; }
}
if ($encrypt_decrypt == 2) { $rsa_decrypt = new Crypt_RSA();
$private_key = "MIICXQIBAAKBgQDcttCaGylMIBfe4rsAragQpXj5UuE8exmFrUTcracHRuCs552h rdvAS2WiOe8fSeZuPkGfo1NBu/d+EhbJEc0lS3JKx1V0wpSyeiNdlvzG4Wh5hVi0 0n4WjCDwq2bfzurXuJrm/dbjxQ7acJ4HWRNGHrPV7EfGi2AA4QBvl+j3MQIDAQAB AoGABgIT+53xqdjVzYNug742bP2UJXVUHEldkH3++eLgQRp000Aa0mPhL4Ld6WSa Vce1NhsLvkS753YubogfhqmtY+GO+rS03+8Od2jY6h/ljRBhAY/b6bPJy1ELNH5T ac8jXNf6PC5LOnNIm97fLq7LQZ3G3GUvsnG2WabELHscngECQQD17oeoSKgFj1g0 Oj60QzF0GPeXkB0kMG6tyYV2L5AMPxmhohUU3pS6WqC04NzNOZNOzpwqhvZByH6B 5rZMfnsZAkEA5b/+SZXkSCgDH/sP2HCMikl9NngCfHA5QUezT6IN9ZaB6lU1tWVC oKaSM9bF0HN4HePEFPf4Q7zo9KZ1qop32QJBAN9VdTY6fPNHoIcVWbojxvYyci3e PsiNfwUtG5kfSkYEy4cABPsFwrSU9posFff80Cxh7mmkVF+a7l+TH3vJ5IkCQGE2 NZBJPghR9dCIWJIKPU0d/z8W1GZ2zaMThYmCVkm930aZu1n/eIulL2OD0rt6wC5V e1gr+/4dZqxt6oe4gzECQQCxy9sST7Nlbb/Yb0MJ9VFh4/W+pIH8dnYV87sCL9i8 XDMD6PipMtS64K7RbPi8wxaCP6W5g1kjU0Z2INJEcQFB ";
$rsa_decrypt->loadKey($private_key); // private key*/
if (!empty($data)) { return $rsa_decrypt->decrypt(base64_decode($data)); } else { return ""; }
}
}
}
/** * simple method to encrypt or decrypt a plain text string * initialization vector(IV) has to be the same when encrypting and decrypting * PHP 5.4.9 * * this is a beginners template for simple encryption decryption * before using this in production environments, please read about encryption * * @param string $action : can be 'encrypt' or 'decrypt' * @param string $string : string to encrypt or decrypt * * @return string */
if (!function_exists('encrypt_decrypt')) { function encrypt_decrypt($action, $string) { $output = false;
$encrypt_method = "AES-256-CBC"; $secret_key = '4ySxqyry98'; $secret_iv = 'BsTsudlvcf';
// hash $key = hash('sha256', $secret_key);
// iv - encrypt method AES-256-CBC expects 16 bytes - else you will get a warning $iv = substr(hash('sha256', $secret_iv), 0, 16);
if ($action == 'encrypt') { $output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv); $output = base64_encode($output); } else if ($action == 'decrypt') { $output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv); }
return $output; } }
$sql0 = "SELECT * FROM site_info WHERE siteinfoid = '1' "; if (!($sth0 = $dbh->prepare($sql0))) { throw new Exception('[' . $sth0->errorCode() . ']: ' . print_r($sth0->errorInfo())); }
if (!$sth0->execute()) { throw new Exception('[' . $sth0->errorCode() . ']: ' . print_r($sth0->errorInfo())); } $row0 = $sth0->fetch(PDO::FETCH_ASSOC);
if (!$sth0->execute()) { throw new Exception('[' . $sth0->errorCode() . ']: ' . print_r($sth0->errorInfo())); }
$site_info = $sth0->fetch(PDO::FETCH_ASSOC);
$sql00 = "SELECT * FROM sys_lang WHERE langstatus = '1' ORDER BY langsort ASC "; if (!($sth00 = $dbh->prepare($sql00))) { throw new Exception('[' . $sth00->errorCode() . ']: ' . print_r($sth00->errorInfo())); }
if (!$sth00->execute()) { throw new Exception('[' . $sth00->errorCode() . ']: ' . print_r($sth00->errorInfo())); }
while ($row00 = $sth00->fetch(PDO::FETCH_ASSOC)) { $arraylangcode[$row00{'langcode'}] = $row00{'langname'}; }
//auto login - get the cookies and checking if (isset($_COOKIE["sinomax_cookies1"]) && isset($_COOKIE["sinomax_cookies2"]) && empty($_SESSION["sinomax_member_id"])) { //user has cookies and not login yet $temp_var = rsa_crypt($_COOKIE["sinomax_cookies1"], 2); //decrypt cookies
$sql = "select * from auto_login where expired_date >= ? and http_user_agent = ? and temp_var = ?"; $parameters = array($nowdate, $_SERVER["HTTP_USER_AGENT"], $_COOKIE["sinomax_cookies1"]); if (!($sth = $dbh->prepare($sql))) { throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo())); }
if (!$sth->execute($parameters)) { throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo())); } $valid_cookies_info = $sth->fetch(PDO::FETCH_ASSOC);
$_SESSION["sinomax_member_id"] = $valid_cookies_info{"member_id"};
$_SESSION["autologin_lasturl"] = $_SERVER['REQUEST_URI'];
//make sure all login should visit index page header("Location: ../" . $_COOKIE["sinomax_cookies2"] . "/index.php");; }
if (!function_exists('yesno')) { function yesno($num) { if ($num == 1) return "Yes";
if ($num == 0) return "No"; } }
if (!function_exists('goindex')) { function goindex() { header("Location: index.php"); } }
if (!function_exists('startsWith')) { function startsWith($haystack, $needle){ $length = strlen($needle); return (substr($haystack, 0, $length) === $needle); } }
if (!function_exists('check_upload_path')) { function check_upload_path($img_file){ $session_path_str = "/uploader/".$_SESSION['KCFINDER']['uploadURL']; $session_path_long = strlen($session_path_str); $path_error = 0; foreach($img_file as $key2=>$pathname){ if($key2 && $pathname){ $submit_path_str = substr($pathname,0,$session_path_long); $submit_path_long = strlen($submit_path_str); $file = str_replace('..' ,'' ,$pathname); if($session_path_long <> $submit_path_long || $session_path_str <> $submit_path_str || !startsWith($file, $session_path_str)){ $path_error = 1; } } } } }
if (!function_exists('for_table_name')) { function for_table_name($for_table) { if ($for_table == "race_info") { return "Race Info"; } } }
if (!function_exists('for_table_option')) { function for_table_option($for_table, $type_num) { $option = "";
if (!empty($type_num)) { if ($for_table == "race_info") { if ($type_num == 1 || $type_num == 2) { $option = "&filenum=15&filetype=4"; } }
} else { //only for non type num item }
return $option; } }
if (!function_exists('langcode2langname')) { function langcode2langname($lancode) { $langname = "";
if ($lancode == "en") $langname = "English"; else if ($lancode == "tc") $langname = "繁體中文"; else if ($lancode == "sc") $langname = "?体中文"; else { }
return $langname; } }
if (!function_exists('race_info_type')) { function race_info_type($typenum) { $typename = "";
if ($typenum == 1) $typename = "Race Info"; else if ($typenum == 2) $typename = "Race News"; else if ($typenum == 3) $typename = "Race Multimedia"; else { }
return $typename; } }
function validateDate($date, $format = 'Y-m-d H:i:s') { $d = DateTime::createFromFormat($format, $date); return $d && $d->format($format) == $date; }
function matched_option($data1, $data2, $type) { if($data1 == $data2){ if($type == "checkbox" || $type == "radiobutton"){ return "checked"; }else if($type == "select"){ return "selected"; }else{}
} }
if (!function_exists('member_status')) { function member_status($status) { global $dbh; $sql = "select * from mas_type_code where deleted = ? and typeid = ? and codeid = ? "; $parameters = array("0", "MEMCLUBSTATUS_MOD", $status);
if (!($sth = $dbh->prepare($sql))) { throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo())); }
if (!$sth->execute($parameters)) { throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo())); }
$member_status = $sth->fetch(PDO::FETCH_ASSOC); $statusname = $member_status{"codedesc_en"};
return $statusname; } }
if (!function_exists('get_fees')) { function get_fees($codeid){ global $dbh;
$sql = "select * from mas_type_code where codeid = ? and typeid = ? and deleted = ?"; $parameters = array($codeid, "FEES", "0"); if (!($sth = $dbh->prepare($sql))) { throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo())); }
if (!$sth->execute($parameters)) { throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo())); }
$fees_info = $sth->fetch(PDO::FETCH_ASSOC); return number_format($fees_info["ext1"],2); } }
if (!function_exists('get_options_modifyform')) { function get_options_modifyform($codeid, $name, $br, $data){ global $dbh;
$sql = "select * from mas_type_code where typeid = ? and deleted = ?"; $parameters = array($codeid, "0"); if (!($sth = $dbh->prepare($sql))) { throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo())); }
if (!$sth->execute($parameters)) { throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo())); }
$content = ""; while($code_info = $sth->fetch(PDO::FETCH_ASSOC)){ $content .= '<label><input type="radio" name="'.$name.'" value="'.$code_info{"codeid"}.'" '.matched_option($data, $code_info{"codeid"}, "radiobutton").'/>'.$code_info{"codedesc_tc"}.'</label>';
if($br == "1") $content .= "<br>"; }
return $content; } }
if (!function_exists('get_options_addform')) { function get_options_addform($typeid, $name, $br){ global $dbh;
$sql = "select * from mas_type_code where typeid = ? and deleted = ?"; $parameters = array($typeid, "0"); if (!($sth = $dbh->prepare($sql))) { throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo())); }
if (!$sth->execute($parameters)) { throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo())); }
$content = ""; while($fees_info = $sth->fetch(PDO::FETCH_ASSOC)){ $content .= '<label><input type="radio" name="'.$name.'" value="'.$fees_info{"codeid"}.'"/>'.$fees_info{"codedesc_tc"}.'</label>';
if($br == "1") $content .= "<br>"; }
return $content; } }
if (!function_exists('getcolumnname')) { function getcolumnname($database, $table, $action) { global $dbh; $sql = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = ? and TABLE_SCHEMA = ?"; $parameters = array($table, $database);
$stmt = $dbh->prepare($sql); $stmt->execute($parameters); $output = array(); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $output[] = $row['COLUMN_NAME']; }
//for insert into table $insert_string = "";
foreach ($output as $key => $field) { if ($key == 0) $insert_string .= "insert into " . $table . " (";
if ($key == sizeof($output) - 1) { $insert_string .= $field . ") "; } else {
$insert_string .= $field . ", ";
} }
foreach ($output as $key => $field) { if ($key == 0) $insert_string .= "values (";
if ($key == sizeof($output) - 1) { $insert_string .= "?) "; } else { $insert_string .= "?, "; }
}
//for update table $update_string = "";
foreach ($output as $key => $field) { if ($key == 0) $update_string .= "update ".$table." set ";
if ($key == sizeof($output) - 1) { $update_string .= $field."=? where $output[0] = ?"; } else { $update_string .= $field."=?, "; } }
if ($action == "insert") return $insert_string;
if ($action == "update") return $update_string; } }
if (!function_exists('get_member_info')) { function get_member_info($hkaaano){ global $dbh;
$sql = "select * from mas_member where deleted = ? and hkaaano = ? and regyear = (select max(regyear) from mas_member where deleted = ? and hkaaano = ?) limit 1"; $parameters = array("0", $hkaaano, "0", $hkaaano); if (!($sth = $dbh->prepare($sql))) { throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo())); }
if (!$sth->execute($parameters)) { throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo())); }
$member_info = $sth->fetch(PDO::FETCH_ASSOC);
return $member_info; } }
if (!function_exists('get_club_info')) { function get_club_info($club_refid, $field){ global $dbh;
$sql = "select * from mas_club where deleted = ? and refid = ?"; $parameters = array("0", $club_refid); if (!($sth = $dbh->prepare($sql))) { throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo())); }
if (!$sth->execute($parameters)) { throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo())); }
$club_info = $sth->fetch(PDO::FETCH_ASSOC);
if(!empty($field)){ return $club_info{"$field"}; }else{ return $club_info; }
} }
if (!function_exists('get_mas_type_code')) { function get_mas_type_code($typeid, $codeid, $field=NULL){ global $dbh;
$sql = "select * from mas_type_code where deleted = ? and typeid = ? and codeid = ?"; $parameters = array("0", $typeid, $codeid); if (!($sth = $dbh->prepare($sql))) { throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo())); }
if (!$sth->execute($parameters)) { throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo())); }
$mastypecode_info = $sth->fetch(PDO::FETCH_ASSOC);
if(!empty($field)){ return $mastypecode_info{"$field"}; }else{ return $mastypecode_info; }
} }
?>
|