| Server IP : 210.245.233.93 / Your IP : 216.73.216.226 Web Server : Apache/2.2.15 (CentOS) System : Linux webserver2.onesolution.com.hk 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64 User : apache ( 48) PHP Version : 5.3.3 Disable Function : exec, shell_exec, system, passthru, popen, proc_open, pcntl_exec MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/hkosl.com/tracking/ |
Upload File : |
<?php
if (!function_exists('bind_pdo')) {
function bind_pdo($sql, $parameters = NULL, $action = NULL)
{
global $dbh;
if ($action == "insert" || $action == "update" || $action == "delete" || empty($action)) {
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()));
}
}
if ($action == "selectone") {
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()));
}
$result = $sth->fetch(PDO::FETCH_ASSOC);
if (!empty($result)) {
foreach ($result as $key => $row) {
$result[$key] = htmlspecialchars_decode($result[$key]);
}
}
return $result;
}
if ($action == "selectall") {
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()));
}
$result = $sth->fetchAll(PDO::FETCH_ASSOC);
if (!empty($result)) {
foreach ($result as $key => $row) {
foreach ($row as $key2 => $row2) {
$result[$key][$key2] = htmlspecialchars_decode($result[$key][$key2]);
}
}
}
return $result;
}
if ($action == "dump") {
return dump_sql($sql, $parameters);
}
}
}
if (!function_exists('dump_sql')) {
function dump_sql($sql, $parameters)
{
$keys = array();
# build a regular expression for each parameter
foreach ($parameters as $key => $value) {
if (is_string($key)) {
$keys[] = '/:' . $key . '/';
} else {
$keys[] = '/[?]/';
}
}
foreach ($parameters as $key2 => $value) {
$parameters[$key2] = "'" . $value . "'";
}
$sql = preg_replace($keys, $parameters, $sql, 1, $count);
#trigger_error('replaced '.$count.' keys');
return $sql;
}
}
function getRealIpAddr() {
if ( !empty( $_SERVER['HTTP_CLIENT_IP'] ) ) //check ip from share internet
{
return $_SERVER['HTTP_CLIENT_IP'];
}
elseif ( !empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) //to check ip is pass from proxy
{
return $_SERVER['HTTP_X_FORWARDED_FOR'];
}
else {
return $_SERVER['REMOTE_ADDR'];
}
return 0;
}