error_reporting(0); /* Configuration file */ // Database $pppconfig['dbtype'] = "MySQL"; $pppconfig['dbhost'] = "127.0.0.1"; $pppconfig['dbport'] = "3306"; $pppconfig['dbname'] = "tmh_iphone"; $pppconfig['dbuname'] = "tmh_iphone"; $pppconfig['dbpass'] = "tmH@iPh0ne"; //Do not edit below $pppconfig['dbprefix'] = "t"; DBInit(); // General $pppconfig['charset'] = "utf-8"; $pppconfig['default_lang'] = "th"; $pppconfig['sessionname'] = "VttSessionID"; //File upload config $pppconfig['rootpath'] = "./"; $pppconfig['upload_tmp_dir'] = $pppconfig['rootpath']."/temp/"; $pppconfig['upload_dir'] = $pppconfig['rootpath']."/uploadedfiles/"; // Item per page $pppconfig['perpage'] = 10; $pppconfig['debug'] = 0; $pppconfig['error_msg'] = $pppconfig['debug_sql'] = array(); $pppconfig['debug_msg_includefile'] = array(); $pppconfig['config_header'] = array(); function parse_signed_request($signed_request, $secret) { list($encoded_sig, $payload) = explode('.', $signed_request, 2); $sig = base64_url_decode($encoded_sig); $data = json_decode(base64_url_decode($payload), true); if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') { error_log('Unknown algorithm. Expected HMAC-SHA256'); return null; } $expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true); if ($sig !== $expected_sig) { error_log('Bad Signed JSON signature!'); return null; } return $data; } function base64_url_decode($input) { return base64_decode(strtr($input, '-_', '+/')); } function GetDBName() { global $pppconfig; return $pppconfig['dbname']; } function GetDBPrefix() { global $pppconfig; return $pppconfig['dbprefix']; } function DBInit() { global $pppconfig; global $dbconn; $dbconn = false; $dbhost = $pppconfig['dbhost'].":".$pppconfig['dbport']; $dbname = $pppconfig['dbname']; $dbuname = $pppconfig['dbuname']; $dbpass = $pppconfig['dbpass']; // Start connection $dbconn = mysql_connect($dbhost,$dbuname,$dbpass); mysql_select_db($dbname,$dbconn); mysql_query("SET NAMES UTF8"); return $dbconn; } // Return result in $array[$row][$col]; function DBGetResult($sql) { global $pppconfig; if($pppconfig['debug']) array_push($pppconfig['debug_sql'],$sql); $out = false; if($sql!="") { PPP_DBGetConn(); $res = mysql_query($sql); if($res) { $out = array(); if(mysql_num_rows($res)>0) { while($dat = mysql_fetch_array($res)) array_push($out,$dat); } } else { array_push($pppconfig['error_msg'],array($sql,mysql_error() ) ); } } return $out; } function DBGetNumRow($sql) { global $pppconfig; if($pppconfig['debug']) array_push($pppconfig['debug_sql'],$sql); $out = 0; if($sql!="") { PPP_DBGetConn(); $res = mysql_query($sql); if($res) { $out = mysql_num_rows($res); } else { array_push($pppconfig['error_msg'],array($sql,mysql_error() ) ); } } return $out; } function DBGetCountRow($sql) { global $pppconfig; if($pppconfig['debug']) array_push($pppconfig['debug_sql'],$sql); $out = 0; if($sql!="") { PPP_DBGetConn(); $res = mysql_query($sql); if($res) { $out = mysql_result($res,0,0); } else { array_push($pppconfig['error_msg'],array($sql,mysql_error() ) ); } } return $out; } // Query , Return true on success or false on failure function DBQuery($sql) { global $pppconfig; if($pppconfig['debug']) array_push($pppconfig['debug_sql'],$sql); if($sql!="") { PPP_DBGetConn(); $res = mysql_query($sql); if($res) { return true; } else { array_push($pppconfig['error_msg'],array($sql,mysql_error() ) ); return false; } } else return false; } function PPP_GetBaseURI() { global $HTTP_SERVER_VARS; if (isset($HTTP_SERVER_VARS['REQUEST_URI'])) { $path = $HTTP_SERVER_VARS['REQUEST_URI']; } else { $path = getenv('REQUEST_URI'); } if ((empty($path)) || (substr($path, -1, 1) == '/')) { $path = getenv('PATH_INFO'); if (empty($path)) { if (isset($HTTP_SERVER_VARS['SCRIPT_NAME'])) { $path = $HTTP_SERVER_VARS['SCRIPT_NAME']; } else { $path = getenv('SCRIPT_NAME'); } } } $path = preg_replace('/[#\?].*/', '', $path); $path = dirname($path); if (preg_match('!^[/\\\]*$!', $path)) { $path = ''; } return $path; } function PPP_DBGetConn() { global $dbconn; return $dbconn; } function PPP_GetBaseURL() { global $HTTP_SERVER_VARS; if (empty($HTTP_SERVER_VARS['HTTP_HOST'])) { $server = getenv('HTTP_HOST'); } else { $server = $HTTP_SERVER_VARS['HTTP_HOST']; } if (isset($HTTP_SERVER_VARS['HTTPS']) && $HTTP_SERVER_VARS['HTTPS'] != 'off') { $proto = 'https://'; } else { $proto = 'http://'; } $path = PPP_GetBaseURI(); return "$proto$server$path/"; } function PPP_Redirect($redirecturl) { if (function_exists('session_write_close')) { session_write_close(); } if (preg_match('!^http!', $redirecturl)) { Header("Location: $redirecturl"); return; } else { $redirecturl = preg_replace('!^/*!', '', $redirecturl); $baseurl = PPP_GetBaseURL(); Header("Location: $baseurl$redirecturl"); } } function PPP_JSRedirect($redirecturl,$alert="") { if($alert != "") { $al = "alert('".$alert."');"; } echo "
"; exit; } function PPP_VarPrepForStore() { $resarray = array(); foreach (func_get_args() as $ourvar) { if (!get_magic_quotes_runtime()) { $ourvar = addslashes($ourvar); } array_push($resarray, $ourvar); } if (func_num_args() == 1) { return $resarray[0]; } else { return $resarray; } } ?>