| 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/onegolf/webadmin/ |
Upload File : |
<?php
require_once('configure.php');
//functions
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('aes_crypt')) {
function aes_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 . 'phpseclib1.0.0');
if (!class_exists('Crypt_AES')) {
include_once('phpseclib1.0.0/Crypt/AES.php');
}
if ($encrypt_decrypt == 1) {
$aes_encrypt = new Crypt_AES();
$aes_encrypt->setKey('Y98Y#8&sPqCa!7Qe%ypu-#25p6u^EsWB5Lmd=*K%8+D?_VRUB*BK@d*_5cuCLqTa3pvH*qs@M6@x7$Lm6yESw!Cw=N_!PCF&65CddNMVpDQzspPrHq2wzLj8G6A#G?sa^2MWnAf+&Pv#K4$CpMLJD%P%P%@eH=p$QMgmPV7?9f_WRsraHq8$WA#Sg#5nq*#_jXsHCQ_F4*5XRLft=QPYMDZ%&bk7&gN8Z$P+CR3j%B^4_WM8zBe2spv3bUC5f*a6');
if (!empty($data)) {
return base64_encode($aes_encrypt->encrypt($data));
} else {
return;
}
}
if ($encrypt_decrypt == 2) {
$aes_decrypt = new Crypt_AES();
$aes_decrypt->setKey('Y98Y#8&sPqCa!7Qe%ypu-#25p6u^EsWB5Lmd=*K%8+D?_VRUB*BK@d*_5cuCLqTa3pvH*qs@M6@x7$Lm6yESw!Cw=N_!PCF&65CddNMVpDQzspPrHq2wzLj8G6A#G?sa^2MWnAf+&Pv#K4$CpMLJD%P%P%@eH=p$QMgmPV7?9f_WRsraHq8$WA#Sg#5nq*#_jXsHCQ_F4*5XRLft=QPYMDZ%&bk7&gN8Z$P+CR3j%B^4_WM8zBe2spv3bUC5f*a6');
if (!empty($data)) {
return $aes_decrypt->decrypt(base64_decode($data));
} else {
return;
}
}
}
}
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()));
} else {
return true;
}
}
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()));
}
return $sth->fetch(PDO::FETCH_ASSOC);
}
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()));
}
return $sth->fetchAll(PDO::FETCH_ASSOC);
}
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 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('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('clean_data')) {
function clean_data($data = array())
{
foreach ($data as $data_name => $data_value) {
if (is_array($data_value)) {
clean_data($data_value);
} else {
$_REQUEST[$data_name] = htmlspecialchars($data_value, ENT_QUOTES);
}
}
}
}
if (!function_exists('validateDate')) {
function validateDate($date, $format = 'Y-m-d H:i:s')
{
if(is_string($date)){
$d = DateTime::createFromFormat($format, $date);
return $d && $d->format($format) == $date;
}else{
return false;
}
}
}
if (!function_exists('insert_record')) {
function insert_record($table_name, $data, $dump_sql = NULL)
{
$result = "";
if (!empty($table_name) && !empty($data)) {
$sql = "insert into `" . $table_name . "` set ";
$parameters = array();
foreach ($data as $table_field => $value) {
$sql .= "`" . $table_field . "` = ?, ";
$parameters[] = $value;
}
$sql = substr_replace($sql, "", -2);
}
if (!empty($dump_sql)) {
$result = dump_sql($sql, $parameters);
} else {
$result = bind_pdo($sql, $parameters);
}
return $result;
}
}
if (!function_exists('update_record')) {
function update_record($table_name, $data, $where, $dump_sql = NULL)
{
$result = "";
if (!empty($table_name) && !empty($data)) {
$sql = "update `" . $table_name . "` set ";
$parameters = array();
foreach ($data as $table_field => $value) {
$sql .= "`" . $table_field . "` = ?, ";
$parameters[] = $value;
}
$sql = substr_replace($sql, "", -2);
$sql .= " where " . $where["sql"];
foreach ($where["parameters"] as $table_field => $value) {
$parameters[] = $value;
}
if (!empty($dump_sql)) {
$result = dump_sql($sql, $parameters);
} else {
$result = bind_pdo($sql, $parameters);
}
}
return $result;
}
}
if (!function_exists('call_curl')) {
function call_curl($url, $postData, $post)
{
if (!empty($post)) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
$result = curl_exec($ch);
curl_close($ch);
} else {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec($ch);
curl_close($ch);
}
return $result;
}
}
if (!function_exists('numberformat')) {
function numberformat($data, $decial_place = 2, $thousand = ",")
{
return number_format($data, $decial_place, ".", $thousand);
}
}
if (!function_exists('_log')) {
function _log($page, $log_id, $log_sql, $log_para)
{
$data = array(
"page" => $page,
"log_id" => $log_id,
"log_sql" => $log_sql,
"log_para" => json_encode($log_para),
"log_query" => dump_sql($log_sql, $log_para),
"createdate" => date("Y-m-d H:i:s"),
);
insert_record("log", $data);
}
}
if (!function_exists('get_master_type_code')) {
function get_master_type_code($typeid, $code = NULL)
{
if (!empty($code)) {
$sql = "select * from master_type_code where typeid = ? and code = ? and deleted = ? order by sort ASC";
$parameters = array($typeid, $code, 0);
$master_type_code_info = bind_pdo($sql, $parameters, "selectone");
} else {
$sql = "select * from master_type_code where typeid = ? and deleted = ? order by sort ASC";
$parameters = array($typeid, 0);
$master_type_code_info = bind_pdo($sql, $parameters, "selectall");
}
return $master_type_code_info;
}
}
if (!function_exists('get_player')) {
function get_player($player_id=NULL)
{
if(!empty($player_id)){
$sql = "select * from player where id = ?";
$parameters = array($player_id);
$result = bind_pdo($sql, $parameters, "selectone");
}else{
$sql = "select * from player where deleted = ? order by name ASC";
$parameters = array(0);
$result = bind_pdo($sql, $parameters, "selectall");
}
return $result;
}
}
if (!function_exists('get_event')) {
function get_event($event_id=NULL)
{
if(!empty($event_id)){
$sql = "select * from event where id = ?";
$parameters = array($event_id);
$result = bind_pdo($sql, $parameters, "selectone");
}else{
$sql = "select * from event where deleted = ?";
$parameters = array(0);
$result = bind_pdo($sql, $parameters, "selectall");
}
return $result;
}
}
if (!function_exists('get_event_player')) {
function get_event_player($event_id=NULL, $player_id=NULL)
{
if(!empty($event_id)){
$sql = "select *, p.id as player_id, p.name as player_name from event_player ep INNER JOIN event e ON ep.event_id = e.id INNER JOIN player p ON ep.player_id = p.id where ep.event_id = ? ";
$parameters = array($event_id);
$result = bind_pdo($sql, $parameters, "selectall");
}else{
$sql = "select *, p.id as player_id, p.name as player_name from event_player ep INNER JOIN event e ON ep.event_id = e.id INNER JOIN player p ON ep.player_id = p.id where player_id = ? ";
$parameters = array($player_id);
$result = bind_pdo($sql, $parameters, "selectall");
}
return $result;
}
}
if (!function_exists('get_scores')) {
function get_scores($event_id=NULL, $player_id=NULL)
{
if(!empty($event_id) && !empty($player_id)){
$sql = "select * from scores where event_id = ? and player_id = ? and deleted = ?";
$parameters = array($event_id, $player_id, 0);
$result = bind_pdo($sql, $parameters, "selectone");
}
if(!empty($event_id) && empty($player_id)){
$sql = "select * from scores where event_id = ? and deleted = ?";
$parameters = array($event_id, 0);
$result = bind_pdo($sql, $parameters, "selectall");
}
if(empty($event_id) && !empty($player_id)){
$sql = "select * from scores where player_id = ? and deleted = ?";
$parameters = array($player_id, 0);
$result = bind_pdo($sql, $parameters, "selectall");
}
if(empty($event_id) && empty($player_id)){
echo "<script>alert('You should select an event or a player first.'); window.location.href='event_index.php';</script>";
exit;
}
return $result;
}
}
if (!function_exists('get_max_par')) {
function get_max_par($event_id, $par)
{
$max_par = 0;
$event_info = get_event($event_id);
if($event_info["max_par"] == 1){
$max_par = (int)$par*2;
}
if($event_info["max_par"] == 2){
$max_par = (int)$par*2-1;
}
return $max_par;
}
}
clean_data($_REQUEST);