| 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/chineseaaedu/webadmin/ |
Upload File : |
<?php
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;
}
}
}
?>