YX-e^N;GA;{P'); define('DB_DATABASE', 'db1027262_sfs'); $http_name = ($_SERVER["HTTPS"] == "on")?'https':'http'; define('SITE_DOMAIN', $http_name.':www.box-fourseasons.com'); define('LANG', 'en' ); define('PRIVATE_KEY', 'sfs2015' ); define('SMTP_FROM', 'noreply@sfs.com' ); define('SMTP_NAME', 'SFS' ); define('DELETE_MIN', 60 * 24 ); define('ONLINE_MIN', 5 ); $school_country = array(); $school_country[] = array('key'=>'AFG' , 'value'=>'Afghanistan'); $school_country[] = array('key'=>'ALA' , 'value'=>'Aland Islands'); $school_country[] = array('key'=>'ALB' , 'value'=>'Albania'); $school_country[] = array('key'=>'DZA' , 'value'=>'Algeria'); $school_country[] = array('key'=>'ASM' , 'value'=>'American Samoa'); $school_country[] = array('key'=>'AND' , 'value'=>'Andorra'); $school_country[] = array('key'=>'AGO' , 'value'=>'Angola'); $school_country[] = array('key'=>'AIA' , 'value'=>'Anguilla'); $school_country[] = array('key'=>'ATA' , 'value'=>'Antarctica'); $school_country[] = array('key'=>'ATG' , 'value'=>'Antigua and Barbuda'); $school_country[] = array('key'=>'ARG' , 'value'=>'Argentina'); $school_country[] = array('key'=>'ARM' , 'value'=>'Armenia'); $school_country[] = array('key'=>'ABW' , 'value'=>'Aruba'); $school_country[] = array('key'=>'AUS' , 'value'=>'Australia'); $school_country[] = array('key'=>'AUT' , 'value'=>'Austria'); $school_country[] = array('key'=>'AZE' , 'value'=>'Azerbaijan'); $school_country[] = array('key'=>'BHS' , 'value'=>'Bahamas'); $school_country[] = array('key'=>'BHR' , 'value'=>'Bahrain'); $school_country[] = array('key'=>'BGD' , 'value'=>'Bangladesh'); $school_country[] = array('key'=>'BRB' , 'value'=>'Barbados'); $school_country[] = array('key'=>'BLR' , 'value'=>'Belarus'); $school_country[] = array('key'=>'BEL' , 'value'=>'Belgium'); $school_country[] = array('key'=>'BLZ' , 'value'=>'Belize'); $school_country[] = array('key'=>'BEN' , 'value'=>'Benin'); $school_country[] = array('key'=>'BMU' , 'value'=>'Bermuda'); $school_country[] = array('key'=>'BTN' , 'value'=>'Bhutan'); $school_country[] = array('key'=>'BOL' , 'value'=>'Bolivia, Plurinational State of'); $school_country[] = array('key'=>'BES' , 'value'=>'Bonaire, Sint Eustatius and Saba'); $school_country[] = array('key'=>'BIH' , 'value'=>'Bosnia and Herzegovina'); $school_country[] = array('key'=>'BWA' , 'value'=>'Botswana'); $school_country[] = array('key'=>'BVT' , 'value'=>'Bouvet Island'); $school_country[] = array('key'=>'BRA' , 'value'=>'Brazil'); $school_country[] = array('key'=>'IOT' , 'value'=>'British Indian Ocean Territory'); $school_country[] = array('key'=>'BRN' , 'value'=>'Brunei Darussalam'); $school_country[] = array('key'=>'BGR' , 'value'=>'Bulgaria'); $school_country[] = array('key'=>'BFA' , 'value'=>'Burkina Faso'); $school_country[] = array('key'=>'BDI' , 'value'=>'Burundi'); $school_country[] = array('key'=>'KHM' , 'value'=>'Cambodia'); $school_country[] = array('key'=>'CMR' , 'value'=>'Cameroon'); $school_country[] = array('key'=>'CAN' , 'value'=>'Canada'); $school_country[] = array('key'=>'CPV' , 'value'=>'Cape Verde'); $school_country[] = array('key'=>'CYM' , 'value'=>'Cayman Islands'); $school_country[] = array('key'=>'CAF' , 'value'=>'Central African Republic'); $school_country[] = array('key'=>'TCD' , 'value'=>'Chad'); $school_country[] = array('key'=>'CHL' , 'value'=>'Chile'); $school_country[] = array('key'=>'CHN' , 'value'=>'China'); $school_country[] = array('key'=>'CXR' , 'value'=>'Christmas Island'); $school_country[] = array('key'=>'CCK' , 'value'=>'Cocos (Keeling) Islands'); $school_country[] = array('key'=>'COL' , 'value'=>'Colombia'); $school_country[] = array('key'=>'COM' , 'value'=>'Comoros'); $school_country[] = array('key'=>'COG' , 'value'=>'Congo'); $school_country[] = array('key'=>'COD' , 'value'=>'Congo, the Democratic Republic of the'); $school_country[] = array('key'=>'COK' , 'value'=>'Cook Islands'); $school_country[] = array('key'=>'CRI' , 'value'=>'Costa Rica'); $school_country[] = array('key'=>'CIV' , 'value'=>'Cote d\'Ivoire'); $school_country[] = array('key'=>'HRV' , 'value'=>'Croatia'); $school_country[] = array('key'=>'CUB' , 'value'=>'Cuba'); $school_country[] = array('key'=>'CUW' , 'value'=>'Curacao'); $school_country[] = array('key'=>'CYP' , 'value'=>'Cyprus'); $school_country[] = array('key'=>'CZE' , 'value'=>'Czech Republic'); $school_country[] = array('key'=>'DNK' , 'value'=>'Denmark'); $school_country[] = array('key'=>'DJI' , 'value'=>'Djibouti'); $school_country[] = array('key'=>'DMA' , 'value'=>'Dominica'); $school_country[] = array('key'=>'DOM' , 'value'=>'Dominican Republic'); $school_country[] = array('key'=>'ECU' , 'value'=>'Ecuador'); $school_country[] = array('key'=>'EGY' , 'value'=>'Egypt'); $school_country[] = array('key'=>'SLV' , 'value'=>'El Salvador'); $school_country[] = array('key'=>'GNQ' , 'value'=>'Equatorial Guinea'); $school_country[] = array('key'=>'ERI' , 'value'=>'Eritrea'); $school_country[] = array('key'=>'EST' , 'value'=>'Estonia'); $school_country[] = array('key'=>'ETH' , 'value'=>'Ethiopia'); $school_country[] = array('key'=>'FLK' , 'value'=>'Falkland Islands (Malvinas)'); $school_country[] = array('key'=>'FRO' , 'value'=>'Faroe Islands'); $school_country[] = array('key'=>'FJI' , 'value'=>'Fiji'); $school_country[] = array('key'=>'FIN' , 'value'=>'Finland'); $school_country[] = array('key'=>'FRA' , 'value'=>'France'); $school_country[] = array('key'=>'GUF' , 'value'=>'French Guiana'); $school_country[] = array('key'=>'PYF' , 'value'=>'French Polynesia'); $school_country[] = array('key'=>'ATF' , 'value'=>'French Southern Territories'); $school_country[] = array('key'=>'GAB' , 'value'=>'Gabon'); $school_country[] = array('key'=>'GMB' , 'value'=>'Gambia'); $school_country[] = array('key'=>'GEO' , 'value'=>'Georgia'); $school_country[] = array('key'=>'DEU' , 'value'=>'Germany'); $school_country[] = array('key'=>'GHA' , 'value'=>'Ghana'); $school_country[] = array('key'=>'GIB' , 'value'=>'Gibraltar'); $school_country[] = array('key'=>'GRC' , 'value'=>'Greece'); $school_country[] = array('key'=>'GRL' , 'value'=>'Greenland'); $school_country[] = array('key'=>'GRD' , 'value'=>'Grenada'); $school_country[] = array('key'=>'GLP' , 'value'=>'Guadeloupe'); $school_country[] = array('key'=>'GUM' , 'value'=>'Guam'); $school_country[] = array('key'=>'GTM' , 'value'=>'Guatemala'); $school_country[] = array('key'=>'GGY' , 'value'=>'Guernsey'); $school_country[] = array('key'=>'GIN' , 'value'=>'Guinea'); $school_country[] = array('key'=>'GNB' , 'value'=>'Guinea-Bissau'); $school_country[] = array('key'=>'GUY' , 'value'=>'Guyana'); $school_country[] = array('key'=>'HTI' , 'value'=>'Haiti'); $school_country[] = array('key'=>'HMD' , 'value'=>'Heard Island and McDonald Islands'); $school_country[] = array('key'=>'VAT' , 'value'=>'Holy See (Vatican City State)'); $school_country[] = array('key'=>'HND' , 'value'=>'Honduras'); $school_country[] = array('key'=>'HKG' , 'value'=>'Hong Kong'); $school_country[] = array('key'=>'HUN' , 'value'=>'Hungary'); $school_country[] = array('key'=>'ISL' , 'value'=>'Iceland'); $school_country[] = array('key'=>'IND' , 'value'=>'India'); $school_country[] = array('key'=>'IDN' , 'value'=>'Indonesia'); $school_country[] = array('key'=>'IRN' , 'value'=>'Iran, Islamic Republic of'); $school_country[] = array('key'=>'IRQ' , 'value'=>'Iraq'); $school_country[] = array('key'=>'IRL' , 'value'=>'Ireland'); $school_country[] = array('key'=>'IMN' , 'value'=>'Isle of Man'); $school_country[] = array('key'=>'ISR' , 'value'=>'Israel'); $school_country[] = array('key'=>'ITA' , 'value'=>'Italy'); $school_country[] = array('key'=>'JAM' , 'value'=>'Jamaica'); $school_country[] = array('key'=>'JPN' , 'value'=>'Japan'); $school_country[] = array('key'=>'JEY' , 'value'=>'Jersey'); $school_country[] = array('key'=>'JOR' , 'value'=>'Jordan'); $school_country[] = array('key'=>'KAZ' , 'value'=>'Kazakhstan'); $school_country[] = array('key'=>'KEN' , 'value'=>'Kenya'); $school_country[] = array('key'=>'KIR' , 'value'=>'Kiribati'); $school_country[] = array('key'=>'PRK' , 'value'=>'Korea, Democratic People\'s Republic of'); $school_country[] = array('key'=>'KOR' , 'value'=>'Korea, Republic of'); $school_country[] = array('key'=>'KWT' , 'value'=>'Kuwait'); $school_country[] = array('key'=>'KGZ' , 'value'=>'Kyrgyzstan'); $school_country[] = array('key'=>'LAO' , 'value'=>'Lao People\'s Democratic Republic'); $school_country[] = array('key'=>'LVA' , 'value'=>'Latvia'); $school_country[] = array('key'=>'LBN' , 'value'=>'Lebanon'); $school_country[] = array('key'=>'LSO' , 'value'=>'Lesotho'); $school_country[] = array('key'=>'LBR' , 'value'=>'Liberia'); $school_country[] = array('key'=>'LBY' , 'value'=>'Libya'); $school_country[] = array('key'=>'LIE' , 'value'=>'Liechtenstein'); $school_country[] = array('key'=>'LTU' , 'value'=>'Lithuania'); $school_country[] = array('key'=>'LUX' , 'value'=>'Luxembourg'); $school_country[] = array('key'=>'MAC' , 'value'=>'Macao'); $school_country[] = array('key'=>'MKD' , 'value'=>'Macedonia, the former Yugoslav Republic of'); $school_country[] = array('key'=>'MDG' , 'value'=>'Madagascar'); $school_country[] = array('key'=>'MWI' , 'value'=>'Malawi'); $school_country[] = array('key'=>'MYS' , 'value'=>'Malaysia'); $school_country[] = array('key'=>'MDV' , 'value'=>'Maldives'); $school_country[] = array('key'=>'MLI' , 'value'=>'Mali'); $school_country[] = array('key'=>'MLT' , 'value'=>'Malta'); $school_country[] = array('key'=>'MHL' , 'value'=>'Marshall Islands'); $school_country[] = array('key'=>'MTQ' , 'value'=>'Martinique'); $school_country[] = array('key'=>'MRT' , 'value'=>'Mauritania'); $school_country[] = array('key'=>'MUS' , 'value'=>'Mauritius'); $school_country[] = array('key'=>'MYT' , 'value'=>'Mayotte'); $school_country[] = array('key'=>'MEX' , 'value'=>'Mexico'); $school_country[] = array('key'=>'FSM' , 'value'=>'Micronesia, Federated States of'); $school_country[] = array('key'=>'MDA' , 'value'=>'Moldova, Republic of'); $school_country[] = array('key'=>'MCO' , 'value'=>'Monaco'); $school_country[] = array('key'=>'MNG' , 'value'=>'Mongolia'); $school_country[] = array('key'=>'MNE' , 'value'=>'Montenegro'); $school_country[] = array('key'=>'MSR' , 'value'=>'Montserrat'); $school_country[] = array('key'=>'MAR' , 'value'=>'Morocco'); $school_country[] = array('key'=>'MOZ' , 'value'=>'Mozambique'); $school_country[] = array('key'=>'MMR' , 'value'=>'Myanmar'); $school_country[] = array('key'=>'NAM' , 'value'=>'Namibia'); $school_country[] = array('key'=>'NRU' , 'value'=>'Nauru'); $school_country[] = array('key'=>'NPL' , 'value'=>'Nepal'); $school_country[] = array('key'=>'NLD' , 'value'=>'Netherlands'); $school_country[] = array('key'=>'NCL' , 'value'=>'New Caledonia'); $school_country[] = array('key'=>'NZL' , 'value'=>'New Zealand'); $school_country[] = array('key'=>'NIC' , 'value'=>'Nicaragua'); $school_country[] = array('key'=>'NER' , 'value'=>'Niger'); $school_country[] = array('key'=>'NGA' , 'value'=>'Nigeria'); $school_country[] = array('key'=>'NIU' , 'value'=>'Niue'); $school_country[] = array('key'=>'NFK' , 'value'=>'Norfolk Island'); $school_country[] = array('key'=>'MNP' , 'value'=>'Northern Mariana Islands'); $school_country[] = array('key'=>'NOR' , 'value'=>'Norway'); $school_country[] = array('key'=>'OMN' , 'value'=>'Oman'); $school_country[] = array('key'=>'PAK' , 'value'=>'Pakistan'); $school_country[] = array('key'=>'PLW' , 'value'=>'Palau'); $school_country[] = array('key'=>'PSE' , 'value'=>'Palestinian Territory, Occupied'); $school_country[] = array('key'=>'PAN' , 'value'=>'Panama'); $school_country[] = array('key'=>'PNG' , 'value'=>'Papua New Guinea'); $school_country[] = array('key'=>'PRY' , 'value'=>'Paraguay'); $school_country[] = array('key'=>'PER' , 'value'=>'Peru'); $school_country[] = array('key'=>'PHL' , 'value'=>'Philippines'); $school_country[] = array('key'=>'PCN' , 'value'=>'Pitcairn'); $school_country[] = array('key'=>'POL' , 'value'=>'Poland'); $school_country[] = array('key'=>'PRT' , 'value'=>'Portugal'); $school_country[] = array('key'=>'PRI' , 'value'=>'Puerto Rico'); $school_country[] = array('key'=>'QAT' , 'value'=>'Qatar'); $school_country[] = array('key'=>'REU' , 'value'=>'Reunion'); $school_country[] = array('key'=>'ROU' , 'value'=>'Romania'); $school_country[] = array('key'=>'RUS' , 'value'=>'Russian Federation'); $school_country[] = array('key'=>'RWA' , 'value'=>'Rwanda'); $school_country[] = array('key'=>'BLM' , 'value'=>'Saint Barthelemy'); $school_country[] = array('key'=>'SHN' , 'value'=>'Saint Helena, Ascension and Tristan da Cunha'); $school_country[] = array('key'=>'KNA' , 'value'=>'Saint Kitts and Nevis'); $school_country[] = array('key'=>'LCA' , 'value'=>'Saint Lucia'); $school_country[] = array('key'=>'MAF' , 'value'=>'Saint Martin (French part)'); $school_country[] = array('key'=>'SPM' , 'value'=>'Saint Pierre and Miquelon'); $school_country[] = array('key'=>'VCT' , 'value'=>'Saint Vincent and the Grenadines'); $school_country[] = array('key'=>'WSM' , 'value'=>'Samoa'); $school_country[] = array('key'=>'SMR' , 'value'=>'San Marino'); $school_country[] = array('key'=>'STP' , 'value'=>'Sao Tome and Principe'); $school_country[] = array('key'=>'SAU' , 'value'=>'Saudi Arabia'); $school_country[] = array('key'=>'SEN' , 'value'=>'Senegal'); $school_country[] = array('key'=>'SRB' , 'value'=>'Serbia'); $school_country[] = array('key'=>'SYC' , 'value'=>'Seychelles'); $school_country[] = array('key'=>'SLE' , 'value'=>'Sierra Leone'); $school_country[] = array('key'=>'SGP' , 'value'=>'Singapore'); $school_country[] = array('key'=>'SXM' , 'value'=>'Sint Maarten (Dutch part)'); $school_country[] = array('key'=>'SVK' , 'value'=>'Slovakia'); $school_country[] = array('key'=>'SVN' , 'value'=>'Slovenia'); $school_country[] = array('key'=>'SLB' , 'value'=>'Solomon Islands'); $school_country[] = array('key'=>'SOM' , 'value'=>'Somalia'); $school_country[] = array('key'=>'ZAF' , 'value'=>'South Africa'); $school_country[] = array('key'=>'SGS' , 'value'=>'South Georgia and the South Sandwich Islands'); $school_country[] = array('key'=>'SSD' , 'value'=>'South Sudan'); $school_country[] = array('key'=>'ESP' , 'value'=>'Spain'); $school_country[] = array('key'=>'LKA' , 'value'=>'Sri Lanka'); $school_country[] = array('key'=>'SDN' , 'value'=>'Sudan'); $school_country[] = array('key'=>'SUR' , 'value'=>'Suriname'); $school_country[] = array('key'=>'SJM' , 'value'=>'Svalbard and Jan Mayen'); $school_country[] = array('key'=>'SWZ' , 'value'=>'Swaziland'); $school_country[] = array('key'=>'SWE' , 'value'=>'Sweden'); $school_country[] = array('key'=>'CHE' , 'value'=>'Switzerland'); $school_country[] = array('key'=>'SYR' , 'value'=>'Syrian Arab Republic'); $school_country[] = array('key'=>'TWN' , 'value'=>'Taiwan, Province of China'); $school_country[] = array('key'=>'TJK' , 'value'=>'Tajikistan'); $school_country[] = array('key'=>'TZA' , 'value'=>'Tanzania, United Republic of'); $school_country[] = array('key'=>'THA' , 'value'=>'Thailand'); $school_country[] = array('key'=>'TLS' , 'value'=>'Timor-Leste'); $school_country[] = array('key'=>'TGO' , 'value'=>'Togo'); $school_country[] = array('key'=>'TKL' , 'value'=>'Tokelau'); $school_country[] = array('key'=>'TON' , 'value'=>'Tonga'); $school_country[] = array('key'=>'TTO' , 'value'=>'Trinidad and Tobago'); $school_country[] = array('key'=>'TUN' , 'value'=>'Tunisia'); $school_country[] = array('key'=>'TUR' , 'value'=>'Turkey'); $school_country[] = array('key'=>'TKM' , 'value'=>'Turkmenistan'); $school_country[] = array('key'=>'TCA' , 'value'=>'Turks and Caicos Islands'); $school_country[] = array('key'=>'TUV' , 'value'=>'Tuvalu'); $school_country[] = array('key'=>'UGA' , 'value'=>'Uganda'); $school_country[] = array('key'=>'UKR' , 'value'=>'Ukraine'); $school_country[] = array('key'=>'ARE' , 'value'=>'United Arab Emirates'); $school_country[] = array('key'=>'GBR' , 'value'=>'United Kingdom'); $school_country[] = array('key'=>'USA' , 'value'=>'United States'); $school_country[] = array('key'=>'UMI' , 'value'=>'United States Minor Outlying Islands'); $school_country[] = array('key'=>'URY' , 'value'=>'Uruguay'); $school_country[] = array('key'=>'UZB' , 'value'=>'Uzbekistan'); $school_country[] = array('key'=>'VUT' , 'value'=>'Vanuatu'); $school_country[] = array('key'=>'VEN' , 'value'=>'Venezuela, Bolivarian Republic of'); $school_country[] = array('key'=>'VNM' , 'value'=>'Viet Nam'); $school_country[] = array('key'=>'VGB' , 'value'=>'Virgin Islands, British'); $school_country[] = array('key'=>'VIR' , 'value'=>'Virgin Islands, U.S.'); $school_country[] = array('key'=>'WLF' , 'value'=>'Wallis and Futuna'); $school_country[] = array('key'=>'ESH' , 'value'=>'Western Sahara'); $school_country[] = array('key'=>'YEM' , 'value'=>'Yemen'); $school_country[] = array('key'=>'ZMB' , 'value'=>'Zambia'); $school_country[] = array('key'=>'ZWE' , 'value'=>'Zimbabwe'); $attainment = array( 1 => 'High school or Equivalent', 2 => 'Associate degree', 3 => 'Bachelor\'s degree', 4 => 'Master\'s degree', 5 => 'MBA', 6 => 'Doctorate' ); $mandarin_proficiency = array( 1 => 'Do not speak', 2 => 'Elementary Mandarin', 3 => 'Everyday conversation' ); $teaching_exp = array( 1 => 'None', 2 => 'Less than 6 months', 3 => '6 months to 1 year', 4 => '1 to 3 years', 5 => '3 to 5 years', 6 => '5 to 10 years', 7 => 'Over 10 years' ); ?>From = $sender_mail; $mail->FromName = $sender_name; $mail->Host = $host; $mail->Mailer = $mailer; $mail->Sender = $sender_mail; $mail->Subject = $subject; $mail->Body = $body; $mail->IsHTML(true); $mail->CharSet = $lang; $mail->AddAddress($receiver_mail, $receiver_name); $mail->Send(); $mail->ClearAddresses(); $mail->ClearAttachments(); } //--- GENERAL FUNCTION END HERE ---// //*** USER FUNCTION START HERE ***// function checkLoginSession(){ if(isset($_SESSION['s_nickname']) && isset($_SESSION['s_pwd'])) return 1; return 0; } function getMMID($id) { $sql = "SELECT user_mmid FROM tab_user WHERE user_id = $id"; return mysql_result(getRS($sql), 0, "user_mmid"); } function checkRegistered($user_nickname, $user_email) { $sql = "SELECT COUNT(*) AS num FROM tab_user WHERE user_nickname = '$user_nickname'"; $chk_nickname = mysql_result(getRS($sql), 0, "num"); $sql = "SELECT COUNT(*) AS num FROM tab_user WHERE user_email = '$user_email'"; $chk_email = mysql_result(getRS($sql), 0, "num"); $chk_pass = 0; if ($chk_nickname == 0 && $chk_email == 0) $chk_pass = 0; if ($chk_nickname > 0 && $chk_email == 0) $chk_pass = 1; if ($chk_nickname == 0 && $chk_email > 0) $chk_pass = 2; if ($chk_nickname > 0 && $chk_email > 0) $chk_pass = 3; return $chk_pass; } function createUser($user_nickname, $user_pwd, $user_name, $user_email, $user_tel, $user_birth, $user_gender, $user_hkid, $user_receive) { $mmid = getUniqueID(); $ip = mysql_escape_string($_SERVER['REMOTE_ADDR']); $sql = "INSERT INTO tab_user (user_mmid, ip, post_time, user_nickname, user_pwd, user_name, user_email, user_tel, user_birth, user_gender, user_hkid, user_receive, user_enable) VALUES ('$mmid', '$ip', Now(), '$user_nickname', '$user_pwd', '$user_name', '$user_email', '$user_tel', '$user_birth', '$user_gender', '$user_hkid', '$user_receive', 'YES')"; $rs = getRS($sql); return $mmid; } function getUserNickname($mmid) { $sql = "SELECT user_nickname FROM tab_user WHERE user_mmid = '$mmid'"; $rs = getRS($sql); return mysql_result($rs, 0, "user_nickname"); } function getUser($mmid) { $sql = "SELECT a.*, b.score FROM tab_user AS a LEFT JOIN (SELECT user_mmid, sum(score) AS score FROM tab_score GROUP BY user_mmid) AS b ON (a.user_mmid = b.user_mmid) WHERE a.user_mmid = '$mmid' ORDER BY a.post_time DESC"; return getRS($sql); } function getUserScoreList($mmid, $order) { $sql = "SELECT * FROM tab_score WHERE user_mmid = '$mmid' ORDER BY post_time $order"; return getRS($sql); } function getUserScoreSum($mmid) { $sql = "SELECT SUM(score) AS num FROM tab_score WHERE user_mmid = '$mmid'"; return mysql_result(getRS($sql), 0, "num"); } function setUserSCore($mmid, $score, $reason) { $reason = mysql_escape_string($reason); $sql = "INSERT INTO tab_score (user_mmid, post_time, score, reason, access_role) VALUES ('$mmid', Now(), '$score', '$reason', 'USER')"; return getRS($sql); } function setUserGift($mmid, $score, $reason) { $reason = mysql_escape_string($reason); $sql = "INSERT INTO tab_score (user_mmid, post_time, score, reason, access_role, exchange_status) VALUES ('$mmid', Now(), '$score', '$reason', 'USER', 'NO')"; return getRS($sql); } function checkPwd($nickname, $pwd) { $sql = "SELECT user_mmid FROM tab_user WHERE user_enable = 'YES' AND user_nickname = '$nickname' AND user_pwd = '$pwd'"; return mysql_result(getRS($sql), 0, "user_mmid"); } //--- USER FUNCTION END HERE ---// //*** GIFT FUNCTION START HERE ***// function getAvaGiftUser($mmid) { $score = mysql_result(getUserScoreSum($mmid), 0, "num"); $sql = "SELECT * FROM tab_gift WHERE $score >= gift_point AND gift_current_qty < gift_max_qty ORDER BY gift_point"; return getRS($sql); } function getGiftDetail($gift_name, $mode) { $gift_name = mysql_escape_string($gift_name); if ($mode == 'name') { $sql = "SELECT * FROM tab_gift WHERE gift_name = '$gift_name' AND gift_enable = 'YES'"; } else { $sql = "SELECT * FROM tab_gift WHERE gift_id = '$gift_name' AND gift_enable = 'YES'"; } return getRS($sql); } function getAvaGiftList($all) { if ($all == 0) { $sql = "SELECT * FROM tab_gift WHERE gift_current_qty < gift_max_qty AND gift_enable = 'YES' ORDER BY gift_id "; } else { $sql = "SELECT * FROM tab_gift WHERE gift_enable = 'YES' ORDER BY gift_id "; } return getRS($sql); } //--- GIFT FUNCTION END HERE ---// //*** BBS FUNTION START HERE ***// function getBbsCat() { $sql = "SELECT * FROM tab_bbscat WHERE bbscat_enable = 'YES'"; return getRS($sql); } function isAdminPost($post_id) { $sql = "SELECT admin FROM tab_bbs WHERE post_id = $post_id"; return mysql_result(getRS($sql), 0, "admin"); } function isTopPost($post_id) { $sql = "SELECT top_post FROM tab_bbs WHERE post_id = $post_id"; return mysql_result(getRS($sql), 0, "top_post"); } function getCatThreadList($bbscat_id) { $sql = "SELECT a.*, b.bbscat_title FROM tab_bbs AS a, tab_bbscat AS b WHERE b.bbscat_id = $bbscat_id AND b.bbscat_enable = 'YES' AND a.enable = 'YES' AND a.bbscat_id = b.bbscat_id AND a.parent_post_id IS NULL ORDER BY a.bbscat_id, top_post DESC, a.post_time DESC"; return getRS($sql); } function getThreadList() { $sql = "SELECT a.*, b.bbscat_title, c.user_nickname FROM tab_bbs AS a, tab_bbscat AS b, tab_user AS c WHERE b.bbscat_enable = 'YES' AND a.enable = 'YES' AND a.bbscat_id = b.bbscat_id AND a.parent_post_id IS NULL AND a.user_mmid = c.user_mmid ORDER BY a.bbscat_id, top_post DESC, a.post_time DESC"; return getRS($sql); } function getPost($post_id) { $sql = "SELECT a.*, b.user_nickname, b.user_mmid FROM tab_bbs AS a, tab_user AS b WHERE (a.post_id = $post_id OR a.parent_post_id = $post_id) AND a.enable = 'YES' AND b.user_enable = 'YES' AND a.user_mmid = b.user_mmid ORDER BY a.post_time"; return getRS($sql); } function getPostByPage($post_id, $page, $pagesize) { //$totalrecord = getRecordCount('table_name', 'where_sql', 'special_sql'); $totalrecord = getRecordCount('', '', "SELECT a.*, b.user_nickname, b.user_mmid FROM tab_bbs AS a, tab_user AS b WHERE (a.post_id = $post_id OR a.parent_post_id = $post_id) AND a.enable = 'YES' AND b.user_enable = 'YES' AND a.user_mmid = b.user_mmid"); $totalpage = getPageCount($pagesize, $totalrecord); $sql_limit_start = getPageStart($pagesize, $totalpage, $page); $sql_limit = " LIMIT ".$sql_limit_start.", ".$pagesize; $sql = "SELECT a.*, b.user_nickname, b.user_mmid FROM tab_bbs AS a, tab_user AS b WHERE (a.post_id = $post_id OR a.parent_post_id = $post_id) AND a.enable = 'YES' AND b.user_enable = 'YES' AND a.user_mmid = b.user_mmid ORDER BY a.post_time ".$sql_limit; return getRS($sql); } function getPostTotalPage($post_id, $pagesize) { //$totalrecord = getRecordCount('table_name', 'where_sql', 'special_sql'); $totalrecord = getRecordCount('', '', "SELECT a.*, b.user_nickname, b.user_mmid FROM tab_bbs AS a, tab_user AS b WHERE (a.post_id = $post_id OR a.parent_post_id = $post_id) AND a.enable = 'YES' AND b.user_enable = 'YES' AND a.user_mmid = b.user_mmid"); $totalpage = getPageCount($pagesize, $totalrecord); return $totalpage; } function getCatThreadTotalPage($bbscat_id, $pagesize) { //$totalrecord = getRecordCount('table_name', 'where_sql', 'special_sql'); $totalrecord = getRecordCount('', '', "SELECT a.*, b.bbscat_title FROM tab_bbs AS a, tab_bbscat AS b WHERE b.bbscat_id = $bbscat_id AND b.bbscat_enable = 'YES' AND a.enable = 'YES' AND a.bbscat_id = b.bbscat_id AND a.parent_post_id IS NULL ORDER BY a.bbscat_id, top_post DESC, a.post_time DESC"); $totalpage = getPageCount($pagesize, $totalrecord); return $totalpage; } function getCatThreadListByPage($bbscat_id, $page, $pagesize) { //$totalrecord = getRecordCount('table_name', 'where_sql', 'special_sql'); $totalrecord = getRecordCount('', '', "SELECT a.*, b.bbscat_title FROM tab_bbs AS a, tab_bbscat AS b WHERE b.bbscat_id = $bbscat_id AND b.bbscat_enable = 'YES' AND a.enable = 'YES' AND a.bbscat_id = b.bbscat_id AND a.parent_post_id IS NULL ORDER BY a.bbscat_id, top_post DESC, a.post_time DESC"); $totalpage = getPageCount($pagesize, $totalrecord); $sql_limit_start = getPageStart($pagesize, $totalpage, $page); $sql_limit = " LIMIT ".$sql_limit_start.", ".$pagesize; $sql = "SELECT a.*, b.bbscat_title FROM tab_bbs AS a, tab_bbscat AS b WHERE b.bbscat_id = $bbscat_id AND b.bbscat_enable = 'YES' AND a.enable = 'YES' AND a.bbscat_id = b.bbscat_id AND a.parent_post_id IS NULL ORDER BY a.admin DESC, a.top_post DESC, a.latest_post_time DESC, a.bbscat_id".$sql_limit; return getRS($sql); } function creatThread($mmid, $title, $content, $pic, $cat_id) { $ip = mysql_escape_string($_SERVER['REMOTE_ADDR']); $NOW = date("Y-m-d H:i:s"); $sql = "INSERT INTO tab_bbs (bbscat_id, post_time, ip, enable, post_title, post_content, user_mmid, pic, latest_post_time) VALUES ($cat_id, '$NOW', '$ip', 'YES', '$title', '$content', '$mmid', '$pic', '$NOW')"; getRS($sql); $sql = "SELECT @@IDENTITY AS 'id'"; $post = getRS($sql); $row = mysql_fetch_object($post); $post_id= $row->id; return $post_id; } function replyPost($mmid, $content, $pic, $cat_id, $parent_id) { if (isAllowReply($parent_id)){ $ip = mysql_escape_string($_SERVER['REMOTE_ADDR']); $NOW = date("Y-m-d H:i:s"); $sql = "INSERT INTO tab_bbs (parent_post_id, bbscat_id, post_time, ip, enable, post_content, user_mmid, pic, latest_post_time) VALUES ($parent_id, $cat_id, '$NOW', '$ip', 'YES', '$content', '$mmid', '$pic', '$NOW')"; getRS($sql); $sql = "UPDATE tab_bbs SET latest_post_time = '".$NOW."' WHERE post_id = ".$parent_id; getRS($sql); return true; } return false; } function checkAdminBonus($post_id, $mmid) { if ( (isAdminPost($post_id) == "YES") && (isFirstReply($post_id, $mmid)) ) { $score = ADMIN_POST_SCORE; $reason = "REPLY ADMIN POST AT BBS"; setUserSCore($mmid, $score, $reason); return $score; } else return 0; } function checkTopPostBonus($post_id, $mmid) { if ( (isTopPost($post_id) == "YES") && (isFirstReply($post_id, $mmid)) ) { $score = TOP_POST_SCORE; $reason = "REPLY TOP POST AT BBS"; setUserSCore($mmid, $score, $reason); return $score; } else return 0; } function isFirstReply($post_id, $mmid) { $sql = "SELECT count(*) AS num FROM tab_bbs WHERE ((parent_post_id = '$post_id') OR (post_id = '$post_id')) AND user_mmid = '$mmid'"; $rs = getRS($sql); $total = mysql_result($rs, 0, "num"); if ($total == 1) return true; else return false; } // function breakDown($message, $num, $boo) { // mb_internal_encoding("UTF-8"); // if ($boo != "F") { // $message = mb_substr($message, 0, $num); // return preg_replace("/([a-zA-Z0-9:\/\.]{".$num."})/u", "$1 ", $message)."..."; // } // return preg_replace("/([a-zA-Z0-9:\/\.]{".$num."})/u", "$1 ", $message); // } function isAllowReply($post_id){ $post = getPost($post_id); if ($row = mysql_fetch_object($post)) { $allow_reply = $row->allow_reply; if ($allow_reply == "YES") return true; } return false; } //--- BBS FUNCTION END HERE ---// //*** LEVEL DIPLAY FUNCTION START HERE ***// function getLevel($mmid) { $sql = "SELECT SUM(score) AS num FROM tab_score WHERE user_mmid = '$mmid' and score >= 0"; $rs = getRS($sql); $total = mysql_result($rs, 0, "num"); if ($total==""){ $total = 0; } $sql = "SELECT * FROM tab_level WHERE $total >= min_value AND $total <= max_value"; $rs = getRS($sql); return $rs; } //--- LEVEL DIPLAY FUNCTION END HERE ---// //*** FORWARD FUNCTION START HERE ***// function checkToday($mmid) { $today = date('Y-m-d'); $sql = "SELECT COUNT(*) AS num FROM tab_forward WHERE mmid = '$mmid' AND post_time = '$today'"; $rs = getRS($sql); return mysql_result($rs, 0, "num"); } function checkFrd($mmid, $frd_email) { $sql = "SELECT COUNT(*) AS num FROM tab_forward WHERE mmid = '$mmid' AND frd_email = '$frd_email'"; $rs = getRS($sql); return mysql_result($rs, 0, "num"); } function addForward($mmid, $frd_name, $frd_email) { $sql = "INSERT INTO tab_forward (mmid, frd_name, frd_email, post_time) VALUES ('$mmid', '$frd_name', '$frd_email', Now())"; getRS($sql); $score = FORWARD_SCORE; setUserSCore($mmid, $score, "INVITE FRIEND"); } //--- FORWARD FUNCTION END HERE ---// //*** POSTER FUNCTION START HERE ***// function addPoster($mmid, $poster_file, $poster_title, $poster_content) { $ip = mysql_escape_string($_SERVER['REMOTE_ADDR']); $pp = checkPoster($mmid); if ($pp == 0) { $score = POSTER_SCORE; setUserSCore($mmid, $score, "JOIN POSTER COMP."); } $sql = "INSERT INTO tab_poster (ip, post_time, mmid, poster_file, poster_title, poster_content) VALUES ('$ip', Now(), '$mmid', '$poster_file', '$poster_title', '$poster_content')"; getRS($sql); return $pp; } function checkPoster($mmid) { $sql = "SELECT COUNT(*) AS num FROM tab_poster WHERE mmid = '$mmid'"; return mysql_result(getRS($sql), 0, "num"); } //--- POSTER FUNCTION END HERE ---// //*** SURVEY FUNCTION START HERE ***// function surveyCheckDuplicate($mmid, $launch) { $sql = "SELECT count(survey_id) AS duplicate FROM tab_survey WHERE mmid = '$mmid' AND launch = '$launch'"; $rs = getRS($sql); return mysql_result($rs, 0, "duplicate"); } function addSurvey($mmid, &$req) { $ip = mysql_escape_string($_SERVER['REMOTE_ADDR']); $sql = "INSERT INTO tab_survey (mmid, launch, q1, q2, q3, q4, q5, q6, q7, q8, q9, q10, q11, q12, q13, q14, q15, q16, q17, q18, q19, q20, q21, q22, q23, q24, q25, q26, q27, q28, q29, q30, extra_1, extra_2, extra_3, extra_4, extra_5, extra_6, extra_7, ip, post_time) VALUES ('$mmid', '".$req['launch']."', '".$req['q1']."', '".$req['q2']."', '".$req['q3']."', '".$req['q4']."', '".$req['q5']."', '".$req['q6']."', '".$req['q7']."', '".$req['q8']."', '".$req['q9']."', '".$req['q10']."', '".$req['q11']."', '".$req['q12']."', '".$req['q13']."', '".$req['q14']."', '".$req['q15']."', '".$req['q16']."', '".$req['q17']."', '".$req['q18']."', '".$req['q19']."', '".$req['q20']."', '".$req['q21']."', '".$req['q22']."', '".$req['q23']."', '".$req['q24']."', '".$req['q25']."', '".$req['q26']."', '".$req['q27']."', '".$req['q28']."', '".$req['q29']."', '".$req['q30']."', '".$req['extra1']."', '".$req['extra2']."', '".$req['extra3']."', '".$req['extra4']."', '".$req['extra5']."', '".$req['extra6']."', '".$req['extra7']."', '$ip', Now())"; getRS($sql); $score = SURVEY_SCORE; setUserSCore($mmid, $score, "JOIN SURVEY : ".$req['launch']); return true; } function surveyQeCheckDuplicate($mmid, $launch) { $sql = "SELECT count(survey_id) AS duplicate FROM tab_survey_qe WHERE mmid = '$mmid' AND launch = '$launch'"; $rs = getRS($sql); return mysql_result($rs, 0, "duplicate"); } function addSurveyQe($mmid, &$req) { $ip = mysql_escape_string($_SERVER['REMOTE_ADDR']); $sql = "INSERT INTO tab_survey_qe (mmid, launch, q1, q2, q3, q4, q5, q6, q7, q8, q9, q10, q11, q12, q13, q14, q15, q16, q17, q18, q19, q20, q21, q22, q23, q24, q25, extra_1, extra_2, extra_3, extra_4, extra_5, ip, post_time) VALUES ('$mmid', '".$req['launch']."', '".$req['q1']."', '".$req['q2']."', '".$req['q3']."', '".$req['q4']."', '".$req['q5']."', '".$req['q6']."', '".$req['q7']."', '".$req['q8']."', '".$req['q9']."', '".$req['q10']."', '".$req['q11']."', '".$req['q12']."', '".$req['q13']."', '".$req['q14']."', '".$req['q15']."', '".$req['q16']."', '".$req['q17']."', '".$req['q18']."', '".$req['q19']."', '".$req['q20']."', '".$req['q21']."', '".$req['q22']."', '".$req['q23']."', '".$req['q24']."', '".$req['q25']."', '".$req['extra1']."', '".$req['extra2']."', '".$req['extra3']."', '".$req['extra4']."', '".$req['extra5']."', '$ip', Now())"; getRS($sql); $score = SURVEY_QE_SCORE; setUserSCore($mmid, $score, "JOIN SURVEY QE : ".$req['launch']); return true; } //--- SURVEY FUNCTION END HERE ---// //*** Ph2 Quiz FUNCTION START HERE ***// function checkQuizPlayb4($quiz, $mmid){ $sql = "SELECT COUNT(*) AS num FROM tab_p2_".$quiz." WHERE user_mmid = '$mmid'"; $rs = getRS($sql); return mysql_result($rs, 0, "num"); } function checkQuizEnable($quiz){ $flag["tf_1"] = true; $flag["tf_2"] = true; $flag["tf_3"] = true; $flag["tf_4"] = true; $flag["tf_5"] = true; $flag["q1"] = true; $flag["q2"] = true; $flag["q3"] = true; $flag["q4"] = true; $flag["q5"] = true; return $flag[$quiz]; } function fillQuestion($gid, $user_mmid, $a1, $a2, $a3, $a4, $a5, $a6, $a7, $a8, $a9, $a10) { $ip = mysql_escape_string($_SERVER['REMOTE_ADDR']); $sql = "INSERT INTO tab_p2_q".$gid." (ip, post_time, user_mmid, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) VALUES ('$ip', Now(), '$user_mmid', '$a1', '$a2', '$a3', '$a4', '$a5', '$a6', '$a7', '$a8', '$a9', '$a10')"; getRS($sql); } function fillQuestion_1($user_mmid, $a1, $a2, $a3, $a4, $a5, $a6, $a7, $a8, $a9, $a10) { $ip = mysql_escape_string($_SERVER['REMOTE_ADDR']); $sql = "INSERT INTO tab_p2_q1 (ip, post_time, user_mmid, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) VALUES ('$ip', Now(), '$user_mmid', '$a1', '$a2', '$a3', '$a4', '$a5', '$a6', '$a7', '$a8', '$a9', '$a10')"; getRS($sql); } function getAnswer_q($gid, $q, $a, $type='letter'){ switch ($gid){ case 1: $ans[1]['question'] = '2008年全港青少年禁毒運動的口號是「不可一‧__ __ __ 」'; $ans[1]['answer'] = 'e'; $ans[1]['display'] = 'horizontal'; $ans[1]['a']['text'] = '只可二'; $ans[1]['b']['text'] = '何況三'; $ans[1]['c']['text'] = '不可四'; $ans[1]['d']['text'] = '不可載'; $ans[1]['e']['text'] = '不可再'; $ans[2]['question'] = '2008年全港青少年禁毒運動宣傳口號的副題是「向毒品說不,向 __ __ 說不」'; $ans[2]['answer'] = 'd'; $ans[2]['display'] = 'horizontal'; $ans[2]['a']['text'] = '感情'; $ans[2]['b']['text'] = '衰人'; $ans[2]['c']['text'] = '朋友'; $ans[2]['d']['text'] = '遺憾'; $ans[2]['e']['text'] = '後悔'; $ans[3]['question'] = '以下哪一句子沒有出現在2008年禁毒宣傳海報背景內,:「向 __ __ 說不。」'; $ans[3]['answer'] = 'c'; $ans[3]['display'] = 'horizontal'; $ans[3]['a']['text'] = '魔鬼'; $ans[3]['b']['text'] = '悔疚'; $ans[3]['c']['text'] = '損友'; $ans[3]['d']['text'] = '恐懼'; $ans[3]['e']['text'] = '逃避'; $ans[4]['question'] = '其中一款的禁毒宣傳海報的主題是:「十七歲的手,震得像 __ __ __。」'; $ans[4]['answer'] = 'a'; $ans[4]['display'] = 'horizontal'; $ans[4]['a']['text'] = '七十歲'; $ans[4]['b']['text'] = '珍多冰'; $ans[4]['c']['text'] = '搭電車'; $ans[4]['d']['text'] = '冰震茶'; $ans[4]['e']['text'] = '跳彈床'; $ans[5]['question'] = '其中一款的禁毒宣傳海報內的主題是:「__ __ 引致尿頻,每一程車都變得漫長。」'; $ans[5]['answer'] = 'd'; $ans[5]['display'] = 'horizontal'; $ans[5]['a']['text'] = '氣水'; $ans[5]['b']['text'] = '飲茶'; $ans[5]['c']['text'] = '唱K'; $ans[5]['d']['text'] = 'K仔'; $ans[5]['e']['text'] = '打機'; $ans[6]['question'] = '禁毒宣傳短片《向毒品說不 (聽醫生話) (一)》的內容提及:'; $ans[6]['answer'] = 'e'; $ans[6]['display'] = 'vertical'; $ans[6]['a']['text'] = '吸食K仔的人飲好少水'; $ans[6]['b']['text'] = '吸食K仔的人多數都要換腎'; $ans[6]['c']['text'] = '吸食K仔的人不喜歡搭巴士'; $ans[6]['d']['text'] = '吸食K仔的人很渴望社交生活'; $ans[6]['e']['text'] = '吸食K仔的人膀胱的容量只得正常人約十分之一'; $ans[7]['question'] = '禁毒宣傳短片《向毒品說不 (聽醫生話)(二)》提及吸食危害精神毒品會導致吸食者:'; $ans[7]['answer'] = 'e'; $ans[7]['display'] = 'vertical'; $ans[7]['a']['text'] = '記憶力衰退'; $ans[7]['b']['text'] = '情緒會失控'; $ans[7]['c']['text'] = '智商、反應時間及思維能力下降'; $ans[7]['d']['text'] = '有機會變成弱智或成為精神病患者'; $ans[7]['e']['text'] = '以上所有'; $ans[8]['question'] = '毒宣傳短片《向毒品說不 (真的愛你)》提醒觀眾:'; $ans[8]['answer'] = 'd'; $ans[8]['display'] = 'vertical'; $ans[8]['a']['text'] = '男性較女性容易染上毒癮'; $ans[8]['b']['text'] = '父母不應該給兒女零用錢'; $ans[8]['c']['text'] = '父母讓兒女吸食毒品係犯法的'; $ans[8]['d']['text'] = '父母對防止兒女吸毒的責任很大'; $ans[8]['e']['text'] = '兒女要甚麼父母都應該盡量給他們'; $ans[9]['question'] = '以下哪裡可找到禁毒宣傳廣告?'; $ans[9]['answer'] = 'e'; $ans[9]['display'] = 'horizontal'; $ans[9]['a']['text'] = '港鐵站'; $ans[9]['b']['text'] = '的士車身'; $ans[9]['c']['text'] = '巴士車身'; $ans[9]['d']['text'] = '電車車身'; $ans[9]['e']['text'] = '以上所有'; $ans[10]['question'] = '2008年的反吸毒口號「不可一‧不可再」的英文版本是:'; $ans[10]['answer'] = 'd'; $ans[10]['display'] = 'vertical'; $ans[10]['a']['text'] = 'No One, No Repeat'; $ans[10]['b']['text'] = 'Not Once, Not Again'; $ans[10]['c']['text'] = 'Not Once, Not Twice'; $ans[10]['d']['text'] = 'Not Now, Not Ever'; $ans[10]['e']['text'] = 'Cannot Once, Cannot Again'; break; case 2: $ans[1]['question'] = '軟性和硬性毒品有甚麼分別?'; $ans[1]['answer'] = 'c'; $ans[1]['display'] = 'vertical'; $ans[1]['a']['text'] = '吸食軟性毒品不會上癮'; $ans[1]['b']['text'] = '硬性毒品多是在心理上產生依賴性'; $ans[1]['c']['text'] = '醫學角度來說無分別,因為服食任何毒品皆會上癮'; $ans[1]['d']['text'] = '軟性毒品為液體或氣體,而硬性毒品則是固體'; $ans[1]['e']['text'] = '吸食軟性毒品沒有違法'; $ans[2]['question'] = '吸食毒品主要有甚麼吸食方式?'; $ans[2]['answer'] = 'e'; $ans[2]['display'] = 'vertical'; $ans[2]['a']['text'] = '靜脈注射'; $ans[2]['b']['text'] = '口服'; $ans[2]['c']['text'] = '吸食毒品揮發氣體'; $ans[2]['d']['text'] = '捲成煙捲狀後點燃吸食'; $ans[2]['e']['text'] = '以上所有'; $ans[3]['question'] = '毒品的分類不包括:'; $ans[3]['answer'] = 'b'; $ans[3]['display'] = 'horizontal'; $ans[3]['a']['text'] = '迷幻劑'; $ans[3]['b']['text'] = '娛樂劑'; $ans[3]['c']['text'] = '鎮抑劑'; $ans[3]['d']['text'] = '興奮劑'; $ans[3]['e']['text'] = '鎮靜劑'; $ans[4]['question'] = '以下哪種毒品屬於迷幻劑?'; $ans[4]['answer'] = 'a'; $ans[4]['display'] = 'horizontal'; $ans[4]['a']['text'] = '大麻'; $ans[4]['b']['text'] = '冰'; $ans[4]['c']['text'] = 'E仔'; $ans[4]['d']['text'] = 'K仔'; $ans[4]['e']['text'] = '可卡因'; $ans[5]['question'] = 'E仔屬於甚麼類型的毒品?'; $ans[5]['answer'] = 'c'; $ans[5]['display'] = 'horizontal'; $ans[5]['a']['text'] = '迷幻劑'; $ans[5]['b']['text'] = '鎮抑劑'; $ans[5]['c']['text'] = '興奮劑'; $ans[5]['d']['text'] = '鎮靜劑'; $ans[5]['e']['text'] = '其他'; $ans[6]['question'] = '可卡因屬於甚麼類型的毒品?'; $ans[6]['answer'] = 'c'; $ans[6]['display'] = 'horizontal'; $ans[6]['a']['text'] = '迷幻劑'; $ans[6]['b']['text'] = '鎮抑劑'; $ans[6]['c']['text'] = '興奮劑'; $ans[6]['d']['text'] = '鎮靜劑'; $ans[6]['e']['text'] = '其他'; $ans[7]['question'] = '藍精靈屬於甚麼類型的毒品?'; $ans[7]['answer'] = 'd'; $ans[7]['display'] = 'horizontal'; $ans[7]['a']['text'] = '迷幻劑'; $ans[7]['b']['text'] = '鎮抑劑'; $ans[7]['c']['text'] = '興奮劑'; $ans[7]['d']['text'] = '鎮靜劑'; $ans[7]['e']['text'] = '其他'; $ans[8]['question'] = '以下哪種毒品屬於興奮劑類別?'; $ans[8]['answer'] = 'a'; $ans[8]['display'] = 'horizontal'; $ans[8]['a']['text'] = '冰'; $ans[8]['b']['text'] = '白粉'; $ans[8]['c']['text'] = '嗎啡針'; $ans[8]['d']['text'] = '藍精靈'; $ans[8]['e']['text'] = '海洛英'; $ans[9]['question'] = 'E仔與以下哪種毒品屬於同一類型?'; $ans[9]['answer'] = 'c'; $ans[9]['display'] = 'horizontal'; $ans[9]['a']['text'] = 'E仔'; $ans[9]['b']['text'] = '忽得'; $ans[9]['c']['text'] = '可卡因'; $ans[9]['d']['text'] = '嗎啡針劑'; $ans[9]['e']['text'] = '以上所有'; $ans[10]['question'] = '迷幻劑與興奮劑的分別是:'; $ans[10]['answer'] = 'd'; $ans[10]['display'] = 'vertical'; $ans[10]['a']['text'] = '吸食迷幻劑比興奮劑容易上癮'; $ans[10]['b']['text'] = '吸食興奮劑比迷幻劑容易上癮'; $ans[10]['c']['text'] = 'E仔屬於興奮劑,而海洛英屬於迷幻劑'; $ans[10]['d']['text'] = '吸食興奮劑會導致失眠,而吸食迷幻劑會導致心跳加速和血壓上升'; $ans[10]['e']['text'] = '沒有分別'; break; case 3: $ans[1]['question'] = '吸食大麻導致的害處包括:'; $ans[1]['answer'] = 'e'; $ans[1]['display'] = 'vertical'; $ans[1]['a']['text'] = '舉止遲鈍'; $ans[1]['b']['text'] = '在判斷及記憶方面發生障礙'; $ans[1]['c']['text'] = '緊張、激動及脾氣暴躁'; $ans[1]['d']['text'] = '抑鬱及對別人極度懷疑'; $ans[1]['e']['text'] = '以上所有害處'; $ans[2]['question'] = '吸毒不會導致:'; $ans[2]['answer'] = 'c'; $ans[2]['display'] = 'vertical'; $ans[2]['a']['text'] = '死亡'; $ans[2]['b']['text'] = '上癮'; $ans[2]['c']['text'] = '皮膚嫩滑'; $ans[2]['d']['text'] = '腦部受損'; $ans[2]['e']['text'] = '判斷力失準'; $ans[3]['question'] = '吸食海洛英造成的後果不包括:'; $ans[3]['answer'] = 'd'; $ans[3]['display'] = 'vertical'; $ans[3]['a']['text'] = '便秘'; $ans[3]['b']['text'] = '視力減退'; $ans[3]['c']['text'] = '呼吸抑制'; $ans[3]['d']['text'] = '性衝動加強'; $ans[3]['e']['text'] = '情緒不穩定'; $ans[4]['question'] = '海洛英的特徵包括:'; $ans[4]['answer'] = 'e'; $ans[4]['display'] = 'vertical'; $ans[4]['a']['text'] = '一旦成癮極難戒治'; $ans[4]['b']['text'] = '具高度心理及生理依賴性'; $ans[4]['c']['text'] = '無法集中精神,會產生夢幻覺,過量使用會造成急性中毒'; $ans[4]['d']['text'] = '停藥會產生發抖、打冷顫、身體捲曲、抽筋等戒斷症狀'; $ans[4]['e']['text'] = '以上所有特徵'; $ans[5]['question'] = '吸食可卡因的後果不包括:'; $ans[5]['answer'] = 'e'; $ans[5]['display'] = 'vertical'; $ans[5]['a']['text'] = '肌肉抽痛'; $ans[5]['b']['text'] = '極度激動不安'; $ans[5]['c']['text'] = '被迫害的感覺'; $ans[5]['d']['text'] = '脈搏徵弱而且急促'; $ans[5]['e']['text'] = '呼吸緩慢及呼吸量淺'; $ans[6]['question'] = '毒品的戒斷症狀所指的是甚麼?'; $ans[6]['answer'] = 'e'; $ans[6]['display'] = 'vertical'; $ans[6]['a']['text'] = '吸食毒品的分量'; $ans[6]['b']['text'] = '戒毒所需的時間'; $ans[6]['c']['text'] = '吸食毒品的後遺症'; $ans[6]['d']['text'] = '難以戒毒的原因'; $ans[6]['e']['text'] = '當不再使用毒品後身體出現的反應'; $ans[7]['question'] = '吸食K仔的後果包括但不限於:'; $ans[7]['answer'] = 'e'; $ans[7]['display'] = 'vertical'; $ans[7]['a']['text'] = '行動機能受損'; $ans[7]['b']['text'] = '呼吸/心臟機能受損'; $ans[7]['c']['text'] = '動作協調神經系統受損'; $ans[7]['d']['text'] = '長期記憶力衰退及認知能力受損'; $ans[7]['e']['text'] = '以上所有'; $ans[8]['question'] = '吸食「黑芝麻」的後果包括但不限於:'; $ans[8]['answer'] = 'e'; $ans[8]['display'] = 'vertical'; $ans[8]['a']['text'] = '舉止失常'; $ans[8]['b']['text'] = '噁心和嘔吐'; $ans[8]['c']['text'] = '判斷力失準'; $ans[8]['d']['text'] = '心跳加速和血壓上升'; $ans[8]['e']['text'] = '以上所有'; $ans[9]['question'] = '睡眠失調是吸食以下哪一種毒品的後果?'; $ans[9]['answer'] = 'b'; $ans[9]['display'] = 'horizontal'; $ans[9]['a']['text'] = 'E仔'; $ans[9]['b']['text'] = '忽得'; $ans[9]['c']['text'] = '大麻'; $ans[9]['d']['text'] = '可卡因'; $ans[9]['e']['text'] = '以上所有'; $ans[10]['question'] = '吸食毒品所形成的"耐藥性"是指甚麼?'; $ans[10]['answer'] = 'c'; $ans[10]['display'] = 'vertical'; $ans[10]['a']['text'] = '毒品的效果'; $ans[10]['b']['text'] = '對不吸食毒品的忍耐力'; $ans[10]['c']['text'] = '使用毒品的用量越變越多'; $ans[10]['d']['text'] = '吸食毒品後的感覺更加持久'; $ans[10]['e']['text'] = '吸食毒品過量,用藥物去醫都醫不好'; break; case 4: $ans[1]['question'] = '根據保安局禁毒處《藥物濫用資料中央檔案室》2007年全年的毒品吸食數字 (T3),最常被廿一歲以下人士吸食的毒品是:'; $ans[1]['answer'] = 'd'; $ans[1]['display'] = 'vertical'; $ans[1]['a']['text'] = '冰'; $ans[1]['b']['text'] = '大麻'; $ans[1]['c']['text'] = '海洛英 (白粉)'; $ans[1]['d']['text'] = '氯胺酮 (K仔)'; $ans[1]['e']['text'] = '搖頭丸 (E仔)'; $ans[2]['question'] = '根據保安局禁毒處《藥物濫用資料中央檔案室》2008年上半年的毒品吸食數字 (T10),廿一歲以下首次吸食毒品的平均年齡是:'; $ans[2]['answer'] = 'a'; $ans[2]['display'] = 'vertical'; $ans[2]['a']['text'] = '男15歲、女15歲'; $ans[2]['b']['text'] = '男16歲、女15歲'; $ans[2]['c']['text'] = '男17歲、女16歲'; $ans[2]['d']['text'] = '男18歲、女17歲'; $ans[2]['e']['text'] = '男19歲、女18歲'; $ans[3]['question'] = '根據保安局禁毒處《藥物濫用資料中央檔案室》2008年上半年的毒品吸食數字 (T10),有多少首次吸食毒品的女生平均年齡是16歲或以下:'; $ans[3]['answer'] = 'a'; $ans[3]['display'] = 'horizontal'; $ans[3]['a']['text'] = '41.4%'; $ans[3]['b']['text'] = '38.2%'; $ans[3]['c']['text'] = '37.6%'; $ans[3]['d']['text'] = '37.9%'; $ans[3]['e']['text'] = '37%'; $ans[4]['question'] = '根據保安局禁毒處《藥物濫用資料中央檔案室》2008年上半年的毒品吸食數字 (T3),增幅最大的被吸食毒品是:'; $ans[4]['answer'] = 'd'; $ans[4]['display'] = 'horizontal'; $ans[4]['a']['text'] = '冰'; $ans[4]['b']['text'] = '大麻'; $ans[4]['c']['text'] = '可卡因'; $ans[4]['d']['text'] = '氯胺酮'; $ans[4]['e']['text'] = '海洛英'; $ans[5]['question'] = '根據保安局禁毒處《藥物濫用資料中央檔案室》2007年全年的毒品吸食數字 (T7),在被呈報人士中最常見的吸食毒品原因是:'; $ans[5]['answer'] = 'e'; $ans[5]['display'] = 'vertical'; $ans[5]['a']['text'] = '出於好奇'; $ans[5]['b']['text'] = '解悶∕情緒低落∕焦慮'; $ans[5]['c']['text'] = '尋求快感或官能上的滿足'; $ans[5]['d']['text'] = '避免因沒有吸食毒品而感到不適'; $ans[5]['e']['text'] = '受到同輩朋友影響∕想和同輩朋友打成一片'; $ans[6]['question'] = '根據保安局禁毒處《藥物濫用資料中央檔案室》2007年全年的毒品吸食數字 (T27),有多少吸食毒品人士是學生:'; $ans[6]['answer'] = 'b'; $ans[6]['display'] = 'horizontal'; $ans[6]['a']['text'] = '4.6%'; $ans[6]['b']['text'] = '5.9%'; $ans[6]['c']['text'] = '8.0%'; $ans[6]['d']['text'] = '32.5%'; $ans[6]['e']['text'] = '49.0%'; $ans[7]['question'] = '根據保安局禁毒處《藥物濫用資料中央檔案室》2008上半年的毒品吸食數字 (T27),吸食毒品人士最多數是:'; $ans[7]['answer'] = 'b'; $ans[7]['display'] = 'vertical'; $ans[7]['a']['text'] = '學生'; $ans[7]['b']['text'] = '失業人士'; $ans[7]['c']['text'] = '全職工作人士'; $ans[7]['d']['text'] = '散工∕兼職工作人士'; $ans[7]['e']['text'] = '其他'; $ans[8]['question'] = '根據保安局禁毒處《藥物濫用資料中央檔案室》2008上半年的毒品吸食數字 (T30),最普遍的吸食毒品地點是:'; $ans[8]['answer'] = 'c'; $ans[8]['display'] = 'vertical'; $ans[8]['a']['text'] = '的士高/卡拉OK'; $ans[8]['b']['text'] = '電子遊戲機中心'; $ans[8]['c']['text'] = '只在家/朋友的家'; $ans[8]['d']['text'] = '休憩地方/公園/公廁'; $ans[8]['e']['text'] = '在家/朋友的家及其他地點'; $ans[9]['question'] = '根據香港法例134章,第8條的《危險藥物條例》:'; $ans[9]['answer'] = 'e'; $ans[9]['display'] = 'vertical'; $ans[9]['a']['text'] = '年滿18歲人士被證實吸服危險藥物,一經定罪,最高刑罰是罰款10萬元及禁監3年'; $ans[9]['b']['text'] = '任何人被證實吸服危險藥物,最高刑罰是罰款10萬元及禁監3年'; $ans[9]['c']['text'] = '任何人被證實販賣危險藥物,一經定罪,最高刑罰是罰款10萬元及禁監3年'; $ans[9]['d']['text'] = '任何人被證實吸服危險藥物,一經定罪,最高刑罰是罰款1萬元及禁監1年'; $ans[9]['e']['text'] = '任何人被證實吸服危險藥物,一經循簡易程序定罪後,最高刑罰是罰款10萬元及禁監3年'; $ans[10]['question'] = '根據保安局禁毒處《藥物濫用資料中央檔案室》2008上半年的毒品吸食數字 (T1),首次被呈報人士多數屬於哪一個年齡組別:'; $ans[10]['answer'] = 'b'; $ans[10]['display'] = 'vertical'; $ans[10]['a']['text'] = '15歲或以下'; $ans[10]['b']['text'] = '16 - 20歲'; $ans[10]['c']['text'] = '21 - 25歲'; $ans[10]['d']['text'] = '26 - 30歲'; $ans[10]['e']['text'] = '31歲或以上'; break; case 5: $ans[1]['question'] = '吸食K仔及忽得的後果有甚麼相同?'; $ans[1]['answer'] = 'a'; $ans[1]['display'] = 'vertical'; $ans[1]['a']['text'] = '說話含糊'; $ans[1]['b']['text'] = '睡眠失調'; $ans[1]['c']['text'] = '形成耐藥性'; $ans[1]['d']['text'] = '中毒性精神病'; $ans[1]['e']['text'] = '以上所有'; $ans[2]['question'] = '以下哪一項不是危害精神毒品?'; $ans[2]['answer'] = 'd'; $ans[2]['display'] = 'horizontal'; $ans[2]['a']['text'] = 'K仔'; $ans[2]['b']['text'] = '大麻'; $ans[2]['c']['text'] = '冰'; $ans[2]['d']['text'] = '海洛英'; $ans[2]['e']['text'] = 'LSD'; $ans[3]['question'] = '氯安酮有醫藥用途嗎?'; $ans[3]['answer'] = 'b'; $ans[3]['display'] = 'vertical'; $ans[3]['a']['text'] = '有,鎮靜神經'; $ans[3]['b']['text'] = '有,手術用的麻醉劑'; $ans[3]['c']['text'] = '有,治療發作性渴睡症'; $ans[3]['d']['text'] = '有,防止因戒除毒癮所引起的不適'; $ans[3]['e']['text'] = '沒有醫藥用途'; $ans[4]['question'] = '以漫畫形式帶出禁毒訊息的書名是:'; $ans[4]['answer'] = 'd'; $ans[4]['display'] = 'vertical'; $ans[4]['a']['text'] = '《傑仔係飯桶》'; $ans[4]['b']['text'] = '《傑仔愛吃飯》'; $ans[4]['c']['text'] = '《傑仔開飯啦》'; $ans[4]['d']['text'] = '《傑仔的飯盒》'; $ans[4]['e']['text'] = '《傑仔的筆盒》'; $ans[5]['question'] = '負責統籌及推行反吸毒政策及措施的禁毒處隸屬於以下哪一個政策局/政府部門?'; $ans[5]['answer'] = 'b'; $ans[5]['display'] = 'vertical'; $ans[5]['a']['text'] = '環境局'; $ans[5]['b']['text'] = '保安局'; $ans[5]['c']['text'] = '教育局'; $ans[5]['d']['text'] = '食物及衛生局'; $ans[5]['e']['text'] = '香港警務處'; $ans[6]['question'] = '根據律政司司長黃仁龍在2008年7月4日出席的禁毒教育研討會上的發言,禁毒預防教育由哪裡開始?'; $ans[6]['answer'] = 'b'; $ans[6]['display'] = 'horizontal'; $ans[6]['a']['text'] = '媒體'; $ans[6]['b']['text'] = '校園'; $ans[6]['c']['text'] = '家庭'; $ans[6]['d']['text'] = '朋友'; $ans[6]['e']['text'] = '自己'; $ans[7]['question'] = '香港提供戒毒治療及康復服務的機構包括:'; $ans[7]['answer'] = 'e'; $ans[7]['display'] = 'vertical'; $ans[7]['a']['text'] = '東華三院'; $ans[7]['b']['text'] = '香港明愛'; $ans[7]['c']['text'] = '方舟行動'; $ans[7]['d']['text'] = '聖士提反會'; $ans[7]['e']['text'] = '以上所有'; $ans[8]['question'] = '「Y!他村」計劃的經費來自:'; $ans[8]['answer'] = 'b'; $ans[8]['display'] = 'vertical'; $ans[8]['a']['text'] = '雅虎香港'; $ans[8]['b']['text'] = '禁毒基金'; $ans[8]['c']['text'] = '香港海關'; $ans[8]['d']['text'] = '香港警務處'; $ans[8]['e']['text'] = '香港賽馬會'; $ans[9]['question'] = '香港賽馬會藥物資訊天地共有幾多層?'; $ans[9]['answer'] = 'b'; $ans[9]['display'] = 'horizontal'; $ans[9]['a']['text'] = '1'; $ans[9]['b']['text'] = '2'; $ans[9]['c']['text'] = '3'; $ans[9]['d']['text'] = '4'; $ans[9]['e']['text'] = '5'; $ans[10]['question'] = '在「不可一.不可再 向毒品說不 向遺憾說不」的單張內沒有出現以下哪句句子:'; $ans[10]['answer'] = 'd'; $ans[10]['display'] = 'vertical'; $ans[10]['a']['text'] = '向咳藥說不'; $ans[10]['b']['text'] = '向逃避說不'; $ans[10]['c']['text'] = '向死亡說不'; $ans[10]['d']['text'] = '向失敗說不'; $ans[10]['e']['text'] = '以上所有都出現'; break; default: break; } if ($type=='text'){ return $ans[$q][$a]['text']; } else { return $ans[$q][$a]; } } function checkAnswer_q($gid, $mmid, $type="") { $sql = "SELECT * FROM tab_p2_q".$gid." WHERE user_mmid = '$mmid'"; $rs = getRS($sql); if ($row = mysql_fetch_object($rs)) { $answer[1] = $row->a1; $answer[2] = $row->a2; $answer[3] = $row->a3; $answer[4] = $row->a4; $answer[5] = $row->a5; $answer[6] = $row->a6; $answer[7] = $row->a7; $answer[8] = $row->a8; $answer[9] = $row->a9; $answer[10]= $row->a10; if ($type == 'score'){ $score = 0; for ($i=1; $i<=10; $i++){ if ( $answer[$i] == getAnswer_q( $gid, $i, 'answer') ){ $score = $score + QUIZ1_SCORE; } } if ($score == (QUIZ1_SCORE * 10)){ $score = $score+QUIZ1_BONUS_SCORE; } return $score; } else { for ($i=1; $i<=10; $i++){ if ( $answer[$i] <> getAnswer_q( $gid, $i, 'answer') ){ $a[$i]['no'] = $i; $a[$i]['question'] = getAnswer_q( $gid, $i, 'question'); $a[$i]['w_letter'] = $answer[$i]; $a[$i]['w_text'] = getAnswer_q( $gid, $i, $answer[$i], $type='text'); $a[$i]['r_letter'] = getAnswer_q( $gid, $i, 'answer'); $a[$i]['r_text'] = getAnswer_q( $gid, $i, $a[$i]['r_letter'], $type='text'); } } return $a; } } } function getQuestion_q($gid) { for ($i=1; $i<=10; $i++){ $a[$i]['no'] = $i; $a[$i]['question'] = getAnswer_q( $gid, $i, 'question'); $a[$i]['display'] = getAnswer_q( $gid, $i, 'display'); $a[$i]['a'] = getAnswer_q( $gid, $i, 'a', $type='text'); $a[$i]['b'] = getAnswer_q( $gid, $i, 'b', $type='text'); $a[$i]['c'] = getAnswer_q( $gid, $i, 'c', $type='text'); $a[$i]['d'] = getAnswer_q( $gid, $i, 'd', $type='text'); $a[$i]['e'] = getAnswer_q( $gid, $i, 'e', $type='text'); } return $a; } function fillQuestion_tf($gid, $user_mmid, $a1, $a2, $a3, $a4, $a5, $a6, $a7, $a8, $a9, $a10) { $ip = mysql_escape_string($_SERVER['REMOTE_ADDR']); $sql = "INSERT INTO tab_p2_tf_".$gid." (ip, post_time, user_mmid, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) VALUES ('$ip', Now(), '$user_mmid', '$a1', '$a2', '$a3', '$a4', '$a5', '$a6', '$a7', '$a8', '$a9', '$a10')"; getRS($sql); } function getAnswer_tf($gid, $q, $a){ switch ($gid){ case 1: $ans[1]['question'] = '吸毒不會令人上癮。'; $ans[1]['answer'] = 'F'; $ans[1]['text'] = '吸毒會令人上癮。'; $ans[2]['question'] = '吸毒可以令人快樂。'; $ans[2]['answer'] = 'F'; $ans[2]['text'] = '吸毒不可以令人快樂。'; $ans[3]['question'] = '吸食甲基安非他明(俗稱"冰")有提神的效果。'; $ans[3]['answer'] = 'F'; $ans[3]['text'] = '吸食甲基安非他明(俗稱"冰")會導致失眠、抑鬱、中毒性精神病、食慾不振及心臟和腎臟衰竭,是不會提神的。'; $ans[4]['question'] = '吸毒可導致性無能。'; $ans[4]['answer'] = 'T'; $ans[4]['text'] = ''; $ans[5]['question'] = '脫水,筋疲力盡,肌肉衰弱,體溫過高而痙攣都是吸食E仔的後果。'; $ans[5]['answer'] = 'T'; $ans[5]['text'] = ''; $ans[6]['question'] = '2007年被呈報吸食危害精神毒品的人數首次超越了吸食海洛英的人數。'; $ans[6]['answer'] = 'T'; $ans[6]['text'] = ''; $ans[7]['question'] = '吸食毒品並非犯法。'; $ans[7]['answer'] = 'F'; $ans[7]['text'] = '根據香港法例第134章《危險藥物條例》,吸食毒品是犯法的。'; $ans[8]['question'] = '售賣毒品給成年人並非犯法。'; $ans[8]['answer'] = 'F'; $ans[8]['text'] = '根據香港法例第134章《危險藥物條例》,向任何人出售或供應危險藥物是犯法的。'; $ans[9]['question'] = '根據香港法例第134章《危險藥物條例》,任何人如販運危險藥物(販運是指向他人出售或供應危險藥物),一經定罪,最高可被判處罰款5,000,000港元及終身監禁。'; $ans[9]['answer'] = 'T'; $ans[9]['text'] = ''; $ans[10]['question'] = '聯合國宣布每年的6月26日為國際禁毒日。'; $ans[10]['answer'] = 'T'; $ans[10]['text'] = ''; break; case 2: $ans[1]['question'] = '在2007年被呈報的青少年吸毒個案當中,最經常被吸食的毒品是「K仔」。'; $ans[1]['answer'] = 'T'; $ans[1]['text'] = ''; $ans[2]['question'] = '使用毒品的主要原因包括出於好奇。'; $ans[2]['answer'] = 'T'; $ans[2]['text'] = ''; $ans[3]['question'] = '氯胺酮俗稱「E仔」。'; $ans[3]['answer'] = 'F'; $ans[3]['text'] = '氯胺酮俗稱「K仔」。'; $ans[4]['question'] = '吸食K仔不僅會導致膀胱萎縮、記憶力衰退,還會造成幻覺、幻聽。'; $ans[4]['answer'] = 'T'; $ans[4]['text'] = ''; $ans[5]['question'] = '同時吸食超過一種毒品時,如果每種毒品的劑量大大低於正常劑量,並不足以致命。'; $ans[5]['answer'] = 'F'; $ans[5]['text'] = '同時吸食超過一種毒品時,不論每種毒品的劑量大或細都會大大提高致命的可能性。'; $ans[6]['question'] = '海洛英的英文是"heroin"。'; $ans[6]['answer'] = 'T'; $ans[6]['text'] = ''; $ans[7]['question'] = 'K仔的俗稱為搖頭丸。'; $ans[7]['answer'] = 'F'; $ans[7]['text'] = 'E仔才俗稱為搖頭丸。'; $ans[8]['question'] = '「不可一 ‧不可再 向毒品說不 向遺憾說不」是全港青少年禁毒運動的口號。'; $ans[8]['answer'] = 'T'; $ans[8]['text'] = ''; $ans[9]['question'] = '俗稱為冰的毒品的英文名是methylamphetamine。'; $ans[9]['answer'] = 'T'; $ans[9]['text'] = ''; $ans[10]['question'] = '可卡因的英文是"hocaine"。'; $ans[10]['answer'] = 'F'; $ans[10]['text'] = '可卡因的英文是"cocaine"。'; break; case 3: $ans[1]['question'] = '大麻是香港年青人最常吸食的毒品。'; $ans[1]['answer'] = 'F'; $ans[1]['text'] = 'K仔才是香港年輕人最常吸食的毒品。'; $ans[2]['question'] = '市面上的毒品可能混雜了洗衣粉、老鼠藥、安眠藥和必理痛等。'; $ans[2]['answer'] = 'T'; $ans[2]['text'] = ''; $ans[3]['question'] = '大部分的青年都知道毒品混合的成份。'; $ans[3]['answer'] = 'F'; $ans[3]['text'] = '大部分的青年多數都不知道毒品混合的成份。'; $ans[4]['question'] = '過量服用咳水會產生幻覺和幻聽,繼而抑壓呼吸,甚至導致死亡。'; $ans[4]['answer'] = 'T'; $ans[4]['text'] = ''; $ans[5]['question'] = '「心癮」是指心理上對毒品產生了倚賴。'; $ans[5]['answer'] = 'T'; $ans[5]['text'] = ''; $ans[6]['question'] = '「身癮」是指耐藥性及生理出現變化。'; $ans[6]['answer'] = 'T'; $ans[6]['text'] = ''; $ans[7]['question'] = '「身癮」比「心癮」造成更大的傷害。'; $ans[7]['answer'] = 'F'; $ans[7]['text'] = '「心癮」因為無形,會比「身癮」造成更大的傷害。'; $ans[8]['question'] = '吸食「軟性毒品」不會令人上癮。'; $ans[8]['answer'] = 'F'; $ans[8]['text'] = '毒品無分軟硬,吸食任何毒品都會令人上癮。'; $ans[9]['question'] = '吸食毒品可以減肥。'; $ans[9]['answer'] = 'F'; $ans[9]['text'] = '吸食毒品不可以減肥。'; $ans[10]['question'] = '吸食毒品可以得到好朋友的認同。'; $ans[10]['answer'] = 'F'; $ans[10]['text'] = '吸食毒品會失去好朋友的認同。'; break; case 4: $ans[1]['question'] = '香港的戒毒康復服務有五種戒毒服務。'; $ans[1]['answer'] = 'T'; $ans[1]['text'] = ''; $ans[2]['question'] = '吸食毒品可以得到長期的快樂。'; $ans[2]['answer'] = 'F'; $ans[2]['text'] = '吸食毒品是不可能得到長期的快樂。'; $ans[3]['question'] = '強迫性戒毒治療程序為期2至12個月。'; $ans[3]['answer'] = 'T'; $ans[3]['text'] = ''; $ans[4]['question'] = '吸食少量的K仔不會令人上癮。'; $ans[4]['answer'] = 'F'; $ans[4]['text'] = '吸食少量的K仔已經足以令人上癮。'; $ans[5]['question'] = '長期吸食E仔會嚴重損害腦部及記憶力。'; $ans[5]['answer'] = 'T'; $ans[5]['text'] = ''; $ans[6]['question'] = 'E仔多數以藥丸狀吸食。'; $ans[6]['answer'] = 'T'; $ans[6]['text'] = ''; $ans[7]['question'] = '2007年被呈報吸食精神科毒品的人數乃低於吸食海洛英人數。'; $ans[7]['answer'] = 'F'; $ans[7]['text'] = '2007年吸食精神科毒品的人數已超越吸食海洛英人數。'; $ans[8]['question'] = '吸食「大力丸」後去健身會好大力。'; $ans[8]['answer'] = 'F'; $ans[8]['text'] = '「大力丸」只是俗稱,是不會增強吸食者的力氣。'; $ans[9]['question'] = 'E仔及K仔都屬於迷幻劑毒品。'; $ans[9]['answer'] = 'F'; $ans[9]['text'] = 'E仔屬於興奮劑毒品。'; $ans[10]['question'] = 'K仔、丸仔類毒品已經取代海洛英,成為香港抗毒戰爭中的頭號敵人。'; $ans[10]['answer'] = 'T'; $ans[10]['text'] = ''; break; case 5: $ans[1]['question'] = '在2007年,因觸犯毒品罪行而被捕的人數為6'; $ans[1]['answer'] = 'F'; $ans[1]['text'] = '在2007年,因觸犯毒品罪行而被捕的人數為8,509人。'; $ans[2]['question'] = '領導打擊青少年毒品問題專責小組的律政司司長黃仁龍決定把現行的「濫用藥物」詞彙改為「吸食精神科毒品」。'; $ans[2]['answer'] = 'T'; $ans[2]['text'] = ''; $ans[3]['question'] = '在2007年,以公斤來計,警方和海關檢獲得最多的是氯胺酮(「K仔」)。'; $ans[3]['answer'] = 'F'; $ans[3]['text'] = '在2007年,以公斤來計,警方和海關檢獲得最多的是大麻。'; $ans[4]['question'] = '以上改名的原因是因為青年人會以為如不吸食、不過分,便不會上癮,這皆造成誤導。'; $ans[4]['answer'] = 'T'; $ans[4]['text'] = ''; $ans[5]['question'] = '除了驗血之外,頭髮亦可用來驗證有否吸毒。'; $ans[5]['answer'] = 'T'; $ans[5]['text'] = ''; $ans[6]['question'] = '醫院管理局共開辦了五間物質誤用診所。'; $ans[6]['answer'] = 'T'; $ans[6]['text'] = ''; $ans[7]['question'] = '藥物資訊天地是由香港賽馬會慈善信託基金贊助而興建的。'; $ans[7]['answer'] = 'T'; $ans[7]['text'] = ''; $ans[8]['question'] = '「搖頭丸」導致的搖頭、搖手或搖腳動作都是吸食者跳舞時可以自控的舉動。'; $ans[8]['answer'] = 'F'; $ans[8]['text'] = '「搖頭丸」導致的搖頭、搖手或搖腳動作都是吸食者跳舞時不受自控的舉動。'; $ans[9]['question'] = '「搖頭丸」的英文藥品名是MOMA。'; $ans[9]['answer'] = 'F'; $ans[9]['text'] = '「搖頭丸」的英文藥品名是MDMA。'; $ans[10]['question'] = '香港警察毒品調查科自1997年起為市民服務。'; $ans[10]['answer'] = 'F'; $ans[10]['text'] = '香港警察毒品調查科自1954年起為市民服務。'; break; default: break; } return $ans[$q][$a]; } function getQuestion_tf($gid) { for ($i=1; $i<=10; $i++){ $a[$i]['no'] = $i; $a[$i]['question'] = getAnswer_tf($gid, $i, 'question'); } return $a; } function checkAnswer_tf($gid, $mmid, $type="") { $sql = "SELECT * FROM tab_p2_tf_".$gid." WHERE user_mmid = '$mmid'"; $rs = getRS($sql); if ($row = mysql_fetch_object($rs)) { $answer[1] = $row->a1; $answer[2] = $row->a2; $answer[3] = $row->a3; $answer[4] = $row->a4; $answer[5] = $row->a5; $answer[6] = $row->a6; $answer[7] = $row->a7; $answer[8] = $row->a8; $answer[9] = $row->a9; $answer[10]= $row->a10; if ($type == 'score'){ $score = 0; for ($i=1; $i<=10; $i++){ if ( $answer[$i] == getAnswer_tf($gid, $i, 'answer') ){ $score = $score + TRUE_FALSE_SCORE; } } if ($score == (TRUE_FALSE_SCORE * 10)){ $score = $score+TRUE_FALSE_BONUS_SCORE; } return $score; } else { for ($i=1; $i<=10; $i++){ if ( $answer[$i] <> getAnswer_tf($gid, $i, 'answer') ){ $a[$i]['no'] = $i; $a[$i]['question'] = getAnswer_tf($gid, $i, 'question'); $a[$i]['answer'] = getAnswer_tf($gid, $i, 'answer'); $a[$i]['text'] = getAnswer_tf($gid, $i, 'text'); $a[$i]['wrong'] = 1; } } return $a; } } } //--- Ph2 Quiz FUNCTION END HERE ---// //--- Site Visit START HERE --------------// function setSiteVisit($user_mmid) { $ip = mysql_escape_string($_SERVER['REMOTE_ADDR']); $sql = "INSERT INTO tab_site_visit (ip, post_time, user_mmid) VALUES ('$ip', Now(), '$user_mmid')"; getRS($sql); } function checkSiteVisit($mmid){ $sql = "SELECT COUNT(*) AS num FROM tab_site_visit WHERE user_mmid = '$mmid'"; $rs = getRS($sql); return mysql_result($rs, 0, "num"); } function setSiteVisit2($user_mmid) { $ip = mysql_escape_string($_SERVER['REMOTE_ADDR']); $sql = "INSERT INTO tab_site_visit_2 (ip, post_time, user_mmid) VALUES ('$ip', Now(), '$user_mmid')"; getRS($sql); } function checkSiteVisit2($mmid){ $sql = "SELECT COUNT(*) AS num FROM tab_site_visit_2 WHERE user_mmid = '$mmid'"; $rs = getRS($sql); return mysql_result($rs, 0, "num"); } function setSiteVisit3($user_mmid, $hkid, $hkid_name) { $ip = mysql_escape_string($_SERVER['REMOTE_ADDR']); $sql = "INSERT INTO tab_site_visit_3 (ip, post_time, user_mmid, hkid, hkid_name) VALUES ('".$ip."', Now(), '".$user_mmid."', '".$hkid."', '".$hkid_name."')"; getRS($sql); } function checkSiteVisit3($mmid){ $sql = "SELECT COUNT(*) AS num FROM tab_site_visit_3 WHERE user_mmid = '$mmid'"; $rs = getRS($sql); return mysql_result($rs, 0, "num"); } function setSiteVisit4($user_mmid) { $ip = mysql_escape_string($_SERVER['REMOTE_ADDR']); $sql = "INSERT INTO tab_site_visit_4 (ip, post_time, user_mmid) VALUES ('$ip', Now(), '$user_mmid')"; getRS($sql); } function checkSiteVisit4($mmid){ $sql = "SELECT COUNT(*) AS num FROM tab_site_visit_4 WHERE user_mmid = '$mmid'"; $rs = getRS($sql); return mysql_result($rs, 0, "num"); } function setSiteVisit5($user_mmid) { $ip = mysql_escape_string($_SERVER['REMOTE_ADDR']); $sql = "INSERT INTO tab_site_visit_5 (ip, post_time, user_mmid) VALUES ('$ip', Now(), '$user_mmid')"; getRS($sql); } function checkSiteVisit5($mmid){ $sql = "SELECT COUNT(*) AS num FROM tab_site_visit_5 WHERE user_mmid = '$mmid'"; $rs = getRS($sql); return mysql_result($rs, 0, "num"); } //--- Site Visit END HERE ----------------// //--- VIDEO START HERE --------------// function checkVideo($mmid) { $sql = "SELECT COUNT(*) AS num FROM tab_video WHERE user_mmid = '$mmid'"; $rs = getRS($sql); return mysql_result($rs, 0, "num"); } function setVideo($mmid, $title, $content, $link) { $ip = mysql_escape_string($_SERVER['REMOTE_ADDR']); $sql = "INSERT INTO tab_video ( ip, post_time, user_mmid, title, content, link, enable, view_count ) VALUES ( '$ip', Now(), '$mmid', '$title', '$content', '$link', 'NO', 0 )"; getRS($sql); } function checkVideoLink($mmid, $link) { $sql = "SELECT COUNT(*)AS num FROM tab_video WHERE user_mmid = '$mmid' AND link LIKE '$link%'"; $rs = getRS($sql); return mysql_result($rs, 0, "num"); } function getVideo($id) { $sql = "SELECT * FROM tab_video WHERE enable = 'YES' AND id = '$id'"; return getRS($sql); } function getVideoSQL() { return "SELECT * FROM tab_video WHERE enable = 'YES' ORDER BY post_time DESC"; } //--- VIDEO END HERE ----------------// //--- YAHOO KNOWLEDGE START HERE --------------// function getQuestionList() { $sql = "SELECT * FROM tab_yahoo_know WHERE enable = 'YES' ORDER BY post_time DESC"; return getRS($sql); } function getQuestion($id) { $sql = "SELECT * FROM tab_yahoo_know WHERE enable = 'YES' AND id = '$id'"; return getRS($sql); } function checkTodayPost($mmid) { $s_date = date('Y-m-d'); $sql = "SELECT COUNT(*) AS num FROM tab_yahoo_know WHERE user_mmid = '$mmid' AND DATE(post_time) = '$s_date'"; return mysql_result(getRS($sql), 0, "num"); } function postQuestion($mmid, $question) { $ip = mysql_real_escape_string($_SERVER['REMOTE_ADDR']); $sql = "INSERT INTO tab_yahoo_know( ip, post_time, user_mmid, question, add_score, enable ) VALUES ( '$ip', Now(), '$mmid', '$question', 'NO', 'NO' )"; getRS($sql); } //--- YAHOO KNOWLEDGE END HERE ----------------// ?> ############################################## class paging { var $koneksi; var $p; var $page; var $curr_page; var $curr_query; var $q; var $result; var $next; var $prev; var $number; var $customize = false; //var $ajax = true; var $ajax = false; var $ajax_area = 'main_content'; function paging($curr_page = '' , $curr_query = '' , $record_pre_page=10, $show_paging_num=10, $prev="上一頁", $next="下一頁", $number="%%number%%") { $this->next=''; $this->prev=''; $this->number=$number; $this->curr_page= SITE_DOMAIN.$curr_page; // $this->curr_page = str_replace("listing/listing", "listing", $this->curr_page); // $this->curr_page = str_replace("listing/", "listing", $this->curr_page); // $this->curr_page = str_replace("//", "/", $this->curr_page); $this->curr_query=$curr_query; $this->p["record_pre_page"]=$record_pre_page; $this->p["show_paging_num"]=$show_paging_num; // $_SERVER["QUERY_STRING"]=preg_replace('//[0-9]*/',"",$_SERVER["QUERY_STRING"]); if (empty($_GET["page"])) { $this->page=1; } else { $this->page=$_GET["page"]; } } function db($host,$username,$password,$dbname) { $this->koneksi=mysql_pconnect($host, $username, $password) or die("Connection Error"); mysql_select_db($dbname); return $this->koneksi; } function query($query) { $kondisi=false; // only select if (!preg_match("/^[\s]*select*/i",$query)) { $query="select ".$query; } $querytemp = mysql_query($query, $GLOBALS['gDB_Link']); $this->p["count"]= mysql_num_rows($querytemp); // total page $this->p["total_page"]=ceil($this->p["count"]/$this->p["record_pre_page"]); // filter page if ($this->page<=1) $this->page=1; elseif ($this->page>$this->p["total_page"]) $this->page=$this->p["total_page"]; // awal data yang diambil $this->p["record_start_from"]=$this->page*$this->p["record_pre_page"]-$this->p["record_pre_page"]; $query=$query." limit ".$this->p["record_start_from"].",".$this->p["record_pre_page"]; // die($query); $this->result=mysql_query($query, $GLOBALS['gDB_Link']) or die("Query Error". mysql_error() . '
'.$query ); $arr = array(); while ($row = mysql_fetch_assoc($this->result)) { $arr[] = $row; } return $arr; } function result() { return $result=mysql_fetch_object($this->result); } function result_assoc() { return mysql_fetch_assoc($this->result); } function print_no() { $number=$this->p["record_start_from"]+=1; return $number; } function print_color($color1,$color2) { if (empty($this->p["count_color"])) $this->p["count_color"] = 0; if ( $this->p["count_color"]++ % 2 == 0 ) { return $color=$color1; } else { return $color=$color2; } } function print_info() { $page=array(); $page["start"]=$this->p["record_start_from"]+1; $page["end"]=$this->p["record_start_from"]+$this->p["record_pre_page"]; $page["total"]=$this->p["count"]; $page["total_pages"]=$this->p["total_page"]; if ($page["end"] > $page["total"]) { $page["end"]=$page["total"]; } if (empty($this->p["count"])) { $page["start"]=0; } if (empty($page["total"])) { //$output = "Not Found\n"; $output = ""; } else { if(!$this->customize) $output = "Items $page[start]-$page[end] of $page[total]"; else $output = "Items $page[start]-$page[end] of $page[total]"; } return $output; } function print_link() { //generate template function number($i,$number) { return @ereg_replace("^(.*)%%number%%(.*)$","\\1$i\\2",$number); } $print_link = false; if ($this->p["count"]>$this->p["record_pre_page"] || 1 ) { // print prev if ($this->page>1){ if($this->ajax) $print_link .= "
  • curr_page."".$this->curr_query."".($this->page-1)."','".$this->ajax_area."');\" >".$this->prev."
  • \n"; else $print_link .= "
  • curr_page."/".$this->curr_query."".($this->page-1)."\">".$this->prev."
  • \n"; } // set number // $this->p["bawah"]=$this->page-$this->p["show_paging_num"]; // if ($this->p["bawah"]<1) $this->p["bawah"]=1; $this->p["bawah"]= $this->page - floor(($this->p["show_paging_num"] - 1)/2); if ($this->p["bawah"]<1){ $this->p["bawah"]=1; $left_page = $this->p["show_paging_num"] - $this->page; }else{ $left_page = floor(($this->p["show_paging_num"] )/2); } // $this->p["atas"]=$this->page+$this->p["show_paging_num"]; // if ($this->p["atas"]>$this->p["total_page"]) $this->p["atas"]=$this->p["total_page"]; $this->p["atas"]=$this->page+ $left_page; if ($this->p["atas"]>$this->p["total_page"]) $this->p["atas"]=$this->p["total_page"]; // print start if ($this->page<>1) { for ($i=$this->p["bawah"];$i<=$this->page-1;$i++) if($this->ajax) $print_link .= "curr_page."".$this->curr_query."".$i."','".$this->ajax_area."');\" >".number($i,$this->number)."\n"; else $print_link .="
  • curr_page."".$this->curr_query."/$i\">".number($i,$this->number)."
  • "; } if(!$this->customize){ // print active if ($this->p["total_page"]>1) $print_link .= "
  • ".number($this->page,$this->number)."
  • "; }else{ // print active if ($this->p["total_page"]>1) $print_link .= "
  • ".number($this->page,$this->number)."
  • "; } // print end for ($i=$this->page+1;$i<=$this->p["atas"];$i++) if($this->ajax) $print_link .= "curr_page."".$this->curr_query."".$i."','".$this->ajax_area."');\" >".number($i,$this->number)."\n"; else $print_link .= "
  • curr_page."".$this->curr_query."/$i\">".number($i,$this->number)."
  • "; // print next if ($this->page<$this->p["total_page"]) if($this->ajax) $print_link .= "curr_page."".$this->curr_query."".($this->page+1)."');\" >".$this->next."\n"; else $print_link .= "
  • curr_page."/".$this->curr_query."".($this->page+1)."\">".$this->next."
  • "; return $print_link; } } } ?>db