| 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/littleark/webadmin/ |
Upload File : |
<?php
require_once("configure.php");
if (!function_exists('_h')) {
function _h($str){
return htmlspecialchars($str , ENT_QUOTES);
}
}
if (!function_exists('bind_pdo')) {
function bind_pdo($sql, $parameters = NULL, $action = NULL, $escape = true)
{
global $dbh;
if ($action == "insert" || $action == "update" || $action == "delete" || empty($action)) {
if (!($sth = $dbh->prepare($sql))) {
debug_print_backtrace();
throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo()));
}
if (!$sth->execute($parameters)) {
debug_print_backtrace();
throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo()));
}
}
if ($action == "selectone") {
if (!($sth = $dbh->prepare($sql))) {
debug_print_backtrace();
throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo()));
}
if (!$sth->execute($parameters)) {
debug_print_backtrace();
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] = escape_string($result[$key]);
}
}*/
return $result;
}
if ($action == "selectall") {
if (!($sth = $dbh->prepare($sql))) {
debug_print_backtrace();
throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo()));
}
if (!$sth->execute($parameters)) {
debug_print_backtrace();
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] = escape_string($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;
}
}
if (!function_exists('debug_log')) {
function debug_log($code, $data)
{
$date = new DateTime();
$date->modify("-2 month");
$sql = "delete from debug_log where createdate <= ?";
$parameters = array($date->format("Y-m-d"));
bind_pdo($sql, $parameters);
$sql = "insert into debug_log (code, log_data, createdate) value (?,?,?)";
$parameters = array($code, json_encode($data), date("Y-m-d H:i:s"));
bind_pdo($sql, $parameters);
}
}
if (!function_exists('get_client_ip')) {
function get_client_ip() {
$ipaddress = '';
if (isset($_SERVER['HTTP_CLIENT_IP']))
$ipaddress = $_SERVER['HTTP_CLIENT_IP'];
else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
else if(isset($_SERVER['HTTP_X_FORWARDED']))
$ipaddress = $_SERVER['HTTP_X_FORWARDED'];
else if(isset($_SERVER['HTTP_FORWARDED_FOR']))
$ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
else if(isset($_SERVER['HTTP_FORWARDED']))
$ipaddress = $_SERVER['HTTP_FORWARDED'];
else if(isset($_SERVER['REMOTE_ADDR']))
$ipaddress = $_SERVER['REMOTE_ADDR'];
else
$ipaddress = 'UNKNOWN';
return $ipaddress;
}
}
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, name_en ASC";
$parameters = array($typeid, $code, 0);
$result = bind_pdo($sql, $parameters, "selectone");
} else {
$sql = "select * from master_type_code where typeid = ? and deleted = ? order by sort ASC, name_en ASC";
$parameters = array($typeid, 0);
$result = bind_pdo($sql, $parameters, "selectall");
}
return $result;
}
}
if (!function_exists('get_master_type_code_by_id')) {
function get_master_type_code_by_id($id = NULL)
{
if (!empty($id)) {
$sql = "select * from master_type_code where id = ? ";
$parameters = array($id);
$result = bind_pdo($sql, $parameters, "selectone");
} else {
$sql = "select * from master_type_code where deleted = ? order by name_en ASC";
$parameters = array(0);
$result = bind_pdo($sql, $parameters, "selectall");
}
return $result;
}
}
if (isset($_GET["msg"]) && (int)$_GET["msg"] == $_GET["msg"]) {
$msg_master_info = get_master_type_code("WEBADMIN", $_GET["msg"]);
$msg = $msg_master_info["name_" . $_SESSION["wlangcode"]];
$_GET["msg"] = $msg_master_info["name_" . $_SESSION["wlangcode"]];
}
if (!function_exists('random_string')) {
function random_string($length = 8)
{
$chars = "abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ23456789";
$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('aes_crypt')) {
function aes_crypt($data, $encrypt_decrypt)
{
// updated to phpesclib 2.0
$aes_crypt = new phpseclib\Crypt\AES();
$aes_crypt->setKey('*9Wq*LGBE8GJch?wZUC+8n?WzZb*Y*Lq');
//$aes_crypt->setIV(crypt_random_string($aes_crypt->getBlockLength() >> 3));
$aes_crypt->setIV('d$w5aQCY-STP*MG_hfDxP4eC?uDP@szr');
if ($encrypt_decrypt == 1) {
if (!empty($data)) {
return base64_encode($aes_crypt->encrypt($data));
} else {
return;
}
}
if ($encrypt_decrypt == 2) {
if (!empty($data)) {
return $aes_crypt->decrypt(base64_decode($data));
} else {
return;
}
}
}
}
if (!function_exists('matched_option')) {
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('yesno')) {
function yesno($type, $inputname = NULL, $required = NULL, $data = NULL)
{
if ($type == "addform") {
echo "<input type='radio' name='$inputname' value='1' $required /> Yes";
echo "<input type='radio' name='$inputname' value='0' $required /> No";
}
if ($type == "modifyform") {
echo "<input type='radio' name='$inputname' value='1' " . matched_option($data, 1, "radiobutton") . " $required /> Yes";
echo "<input type='radio' name='$inputname' value='0' " . matched_option($data, 0, "radiobutton") . " $required /> No";
}
if ($type == "readonly") {
if ($data == 1)
echo "Yes";
else
echo "No";
}
}
}
if (!function_exists('select_options')) {
function select_options($rows, $selected_value, $settings = array()){
$langcode = get_langcode() ?: "en";
$settings['value_field'] = $settings['value_field'] ?: 'code';
$settings['label_fn'] = $settings['label_fn'] ?: function($row) use ($langcode) { return "{$row['code']} - {$row["name_{$langcode}"]}"; };
$str = '';
foreach($rows as $row){
$str .= "<option value='" . $row[$settings['value_field']] . "' {$settings['attr']} " . ($row[$settings['value_field']]==$selected_value ? "selected='selected'": "") . ">" . $settings['label_fn']($row) . "</option>";
}
return $str;
}
}
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_supplier')) {
function get_supplier($supplier_id = null, $status = null, $deleted = 0)
{
if (!empty($supplier_id)) {
if (isset($status)) {
$sql = "select * from supplier where id = ? and status = ? and deleted = ? order by code ASC";
$parameters = array($supplier_id, $status, $deleted);
} else {
$sql = "select * from supplier where id = ? and deleted = ? order by code ASC";
$parameters = array($supplier_id, $deleted);
}
$result = bind_pdo($sql, $parameters, "selectone");
} else {
if (isset($status)) {
$sql = "select * from supplier where status = ? and deleted = ? order by code ASC";
$parameters = array($status, $deleted);
} else {
$sql = "select * from supplier where deleted = ? order by code ASC";
$parameters = array($deleted);
}
$result = bind_pdo($sql, $parameters, "selectall");
}
return $result;
}
}
if (!function_exists('validateDate')) {
function validateDate($date, $format = 'Y-m-d H:i:s')
{
$d = DateTime::createFromFormat($format, $date);
return $d && $d->format($format) == $date;
}
}
if (!function_exists('check_image_resolution')) {
function check_image_resolution($image)
{
return true;
/*list($width, $height, $type, $attr) = getimagesize($image);
if ($width <= 2500 && $height <= 2500) {
return true;
} else {
return false;
}*/
}
}