| 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/alliancealliance/webadmin/ |
Upload File : |
<?php
require_once('configure.php');
//functions
if (!function_exists('validate_url')) {
function validate_url()
{
$protocol = strpos(strtolower($_SERVER['SERVER_PROTOCOL']),'https')
=== FALSE ? 'http' : 'https';
$host = $_SERVER['HTTP_HOST'];
$script = $_SERVER['SCRIPT_NAME'];
$request_uri = $_SERVER['REQUEST_URI'];
//$currentUrl = $protocol . '://' . $host . $request_uri;
if (strpos($request_uri, ".php") !== FALSE){
$token = explode(".php", $request_uri);
//check unsafe url character, may add more here
if ( preg_match ( "/\/|\"|\'|>|</", urldecode($token[1]) ) ) {
header("Location: ".$protocol . '://' . $host . $script);
}
}else{
//for index page
if (strpos($request_uri, "?") !== FALSE){
$token = explode("?", $request_uri);
//check unsafe url character, may add more here
if ( preg_match ( "/\/|\"|\'|>|</", urldecode($token[1]) ) ) {
header("Location: ".$protocol . '://' . $host . $token[0]);
}
}
}
}
}
validate_url();
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('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');
include('phpseclib0.3.8/Math/BigInteger.php');
}
if (!class_exists('Net_SSH2')) {
include('phpseclib0.3.8/Net/SSH2.php');
}
if ($encrypt_decrypt == 1) {
$rsa_encrypt = new Crypt_RSA();
$public_key = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDInkMmWTd95fxI5UgXd1UGeTl1 DLSjXv/Z7CJ/y2xHKDpeboVevdko/un6cud4NtYG4iWwC/MXr717dyYA6/8xzFO2 hsgL0qkbEYJWIj0q4ctSZbuni6uim5Yic/MIinE6r43r2tpzkwnlFt+TMUpEapSm Ml3JbopfQcvMa5ANWQIDAQAB
";
$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 = "MIICXAIBAAKBgQDInkMmWTd95fxI5UgXd1UGeTl1DLSjXv/Z7CJ/y2xHKDpeboVe vdko/un6cud4NtYG4iWwC/MXr717dyYA6/8xzFO2hsgL0qkbEYJWIj0q4ctSZbun i6uim5Yic/MIinE6r43r2tpzkwnlFt+TMUpEapSmMl3JbopfQcvMa5ANWQIDAQAB AoGAJtVrziqK8VXphfrL/67byIsCskOpW85x3C83ZmFsLkH9OnZOXs6FEMh3ZkGD yONkfqScAv3tKnKcTR/9PURxe0vwG6Hz05jI0bwl95BSt52ohuocB9oaxgxvdVg4 FfBe/ghi3WTQBhej9E9va4spiDEYaCE1Aw4mCXz+Lsoq+wECQQD+HqmFAPJ0XGHw i0K4F+B4hhQrRQiItSSEyAwvPDnzVHjhrHSKmdeeZT7F9Kn10JADRjTqGf1uC4q3 QwyEghrRAkEAyhpCw7c/NpPdy8W415hGpnPYwHpgFqVJRkcWzLJS63Hd8oJNjEdU ulz452ISoR6BYGSTO3z7HkyMuIzzjjpcCQJBAJlS+skrFx6qFtXB0JGupltR2p14 23tQgCY1ZVSiq/xq/Tx8hxyRUg1Z3RQnWNzd5+Zx179fyw84m4uTQtw4e+ECQGhG gGgm5jCsvmVjEOn8IYfEgfNdsLI+eb4O886Nu4bLa26ymHxmWWsGiU4pJd+Hs80e V3D8HT0W1gxqfUfHCLECQCz2fuK5O78W11GeHSzCKMym0TgUWrBwBBrld9oDJx8r TfZBVwLzHLKBoCBKixfhoMIKMcUvvhkF+wRN+IBJPaQ=";
$rsa_decrypt->loadKey($private_key); // private key*/
if (!empty($data)) {
return $rsa_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('get_site_info')) {
function get_site_info()
{
$sql = "SELECT * FROM site_info WHERE siteinfoid = ? ";
$parameters = array(1);
$site_info = bind_pdo($sql, $parameters, "selectone");
return $site_info;
}
}
$site_info = get_site_info();
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('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('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('get_index_url_parameter')) {
function get_index_url_parameter()
{
$params = $_SERVER['QUERY_STRING'];
$get_index_url_parameter = $params;
return $get_index_url_parameter;
}
}
/*if (!function_exists('get_langcode')) {
function get_langcode()
{
if (strpos($_SERVER['REQUEST_URI'], "/en/") !== FALSE || strpos($_SERVER['REQUEST_URI'], "/tc/") !== FALSE){
$tokens = explode('/', $_SERVER['REQUEST_URI']);
$langcode = $tokens[sizeof($tokens) - 2];
if($langcode != "en" && $langcode != "tc"){
$langcode = "en";
}
return $langcode;
}else{
if(isset($_SESSION["langcode"]))
return $_SESSION["langcode"];
else
return "en";
}
}
}
$langcode = get_langcode();*/
/*if (!empty($langcode)) {
$_SESSION["langcode"] = $langcode;
} else {
$_SESSION["langcode"] = "en";
$langcode = "en";
}*/
$langcode = "en";
if (!function_exists('change_langcode_url')) {
function change_langcode_url()
{
$tokens = explode('/', $_SERVER['REQUEST_URI']);
$langcode_url = $tokens[sizeof($tokens) - 1];
return htmlspecialchars($langcode_url, ENT_QUOTES);
}
}
if(!function_exists('sorting_by_price')){
function sorting_by_price($a, $b)
{
if ($a["lowest_price"] == $b["lowest_price"]) {
return 0;
}
return ($a["lowest_price"] < $b["lowest_price"]) ? -1 : 1;
}
}
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_valid_course_category')){
function get_valid_course_category()
{
//course category at least has a valid course
$valid_course_category_info = array();
$sql = "select * from course_category where status = ? and deleted = ?";
$parameters = array(1, 0);
$course_category_info = bind_pdo($sql, $parameters, "selectall");
foreach($course_category_info as $course_category){
$sql = "select * from course where course_category_id = ? and status = ? and deleted = ?";
$parameters = array($course_category["id"], 1, 0);
$course_info = bind_pdo($sql, $parameters, "selectall");
if(!empty($course_info)){
$valid_course_category_info[] = $course_category;
}
}
return $valid_course_category_info;
}
}
if(!function_exists('get_menu_info')){
function get_menu_info($menu_id)
{
global $langcode;
$sql = "select * from menu where id = ?";
$parameters = array($menu_id);
$this_menu_info = bind_pdo($sql, $parameters, "selectone");
$this_menu_info["desc_".$langcode] = str_replace("../", "", $this_menu_info["desc_".$langcode]);
return $this_menu_info;
}
}
if(!function_exists('get_news_list')){
function get_news_list($type_id, $start=NULL, $limit=NULL)
{
if(isset($start) && isset($limit)){
$limit = "limit ".$start.",".$limit;
}else{
$limit = "";
}
if($type_id == "SPECIAL_OFFERS"){
$sql = "select * from news where typeid = ? and status = ? and deleted = ? order by posted_date DESC ".$limit;
$parameters = array($type_id, 1, 0);
$result = bind_pdo($sql, $parameters, "selectall");
}else{
$sql = "select * from news where typeid = ? and status = ? and deleted = ? and ? between published_from and published_to order by posted_date DESC ".$limit;
$parameters = array($type_id, 1, 0, date("Y-m-d"));
$result = bind_pdo($sql, $parameters, "selectall");
}
return $result;
}
}
if(!function_exists('get_news_detail')){
function get_news_detail($id)
{
$sql = "select * from news where id = ? and status = ? and deleted = ? order by posted_date DESC";
$parameters = array($id, 1, 0);
$result = bind_pdo($sql, $parameters, "selectone");
return $result;
}
}
if(!function_exists('get_enrollment')){
function get_enrollment($id=NULL)
{
if(!empty($id)){
$sql = "select * from enrollment where deleted = ? and id = ? order by enrollment_date DESC, ref_code DESC";
$parameters = array(0, $id);
$result = bind_pdo($sql, $parameters, "selectone");
}else{
$sql = "select * from enrollment where deleted = ? order by enrollment_date DESC, ref_code DESC";
$parameters = array(0);
$result = bind_pdo($sql, $parameters, "selectall");
}
return $result;
}
}
if (!function_exists('get_enrollment_by_email')) {
function get_enrollment_by_email($email)
{
$all_enrollment_info = get_enrollment();
$result = array();
foreach ($all_enrollment_info as $row) {
$decrypt_email = rsa_crypt($row["email"], 2);
if ($email == $decrypt_email) {
$result[] = $row;
}
}
return $result;
}
}
if(!function_exists('get_enrollment_email_list')){
function get_enrollment_email_list()
{
$all_enrollment_info = get_enrollment();
$email_list = array();
foreach($all_enrollment_info as $row){
$exist = false;
$decrypt_email = rsa_crypt($row["email"], 2);
foreach($email_list as $email){
if($email == $decrypt_email){
$exist = true;
}
}
if(!$exist){
$email_list[] = $decrypt_email;
}
}
return $email_list;
}
}
if(!function_exists('get_course')){
function get_course($id=NULL)
{
if(!empty($id)){
$sql = "select * from course where deleted = ? and id = ? order by code ASC";
$parameters = array(0, $id);
$result = bind_pdo($sql, $parameters, "selectone");
}else{
$sql = "select * from course where deleted = ? order by code ASC";
$parameters = array(0);
$result = bind_pdo($sql, $parameters, "selectall");
}
return $result;
}
}
if (!function_exists('get_ref_code')) {
function get_ref_code()
{
$d = new DateTime();
$first_date_month = date("Y-m" . "-01");
$last_date_month = $d->format('Y-m-t');
$sql = "select count(*) as total_num from enrollment where enrollment_date between ? and ?";
$parameters = array($first_date_month, $last_date_month);
$result = bind_pdo($sql, $parameters, "selectone");
$ref_code = "E" . date("y") . date("m") . str_pad(($result["total_num"] + 1), 4, '0', STR_PAD_LEFT);
return $ref_code;
}
}
if(!function_exists('get_company_name')){
function get_company_name($company_name=NULL)
{
if(!empty($company_name)){
$sql = "select * from ra_code where deleted = ? and (company_name_en like ? || company_name_tc like ? ) order by company_name_en ASC";
$parameters = array(0, $company_name);
$result = bind_pdo($sql, $parameters, "selectone");
}else{
$sql = "select * from ra_code where deleted = ? order by company_name_en ASC";
$parameters = array(0);
$result = bind_pdo($sql, $parameters, "selectall");
}
return $result;
}
}
if (!function_exists('check_course_valid_apply')) {
function check_course_valid_apply($course_id)
{
$course_info = get_course($course_id);
$start_date = new DateTime();
$end_date = new DateTime($course_info["end_date"]);
if($start_date->format("Y-m-d") <= $end_date->format("Y-m-d")){
$since_start = $start_date->diff(new DateTime($course_info["end_date"]));
//echo $since_start->days.' days total<br>';
//echo $since_start->d.' days<br>';
if($since_start->d >= 6){ //7 day before
return true;
}else{
return false;
}
}else{
return false;
}
}
}
$sql = "SELECT * FROM sys_lang WHERE langstatus = '1' ORDER BY langsort ASC ";
$lang_array_info = bind_pdo($sql, NULL, "selectall");
foreach ($lang_array_info as $lang_info) {
$arraylangcode[$lang_info{'langcode'}] = $lang_info{'langname'};
}
clean_data($_REQUEST);