| Server IP : 103.48.194.25 / Your IP : 216.73.216.74 Web Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.33 System : Linux VMHostDefault 3.10.0-1160.42.2.el7.x86_64 #1 SMP Tue Sep 7 14:49:57 UTC 2021 x86_64 User : sieuthimay ( 1016) PHP Version : 8.2.20 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/zomuaban.com/public_html/webadmin/helpers/ |
Upload File : |
<?php
function pricevn($price)
{
if(empty($price)) return 'call' ;
return number_format($price, 0,',',".") ;
}
function str_limit($str, $n = 300)
{
if (strlen($str) <= $n)
{
return $str;
}
$limit = strpos($str,' ', $n) ;
while($limit==false&&$n>1)
{ $n--;
$limit = strpos($str,' ', $n) ;
}
$limit = $limit ? $limit : $n ;
$out = substr($str, 0, $limit) ;
return $out.' ...' ;
}
function truncate($text, $length=200, $suffix = '…', $isHTML = true)
{
$i = 0;
$simpleTags=array('br'=>true,'hr'=>true,'input'=>true,'image'=>true,'link'=>true,'meta'=>true);
$tags = array();
if($isHTML){
preg_match_all('/<[^>]+>([^<]*)/', $text, $m, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
foreach($m as $o){
if($o[0][1] - $i >= $length)
break;
$t = substr(strtok($o[0][0], " \t\n\r\0\x0B>"), 1);
// test if the tag is unpaired, then we mustn't save them
if($t[0] != '/' && (!isset($simpleTags[$t])))
$tags[] = $t;
elseif(end($tags) == substr($t, 1))
array_pop($tags);
$i += $o[1][1] - $o[0][1];
}
}
// output without closing tags
$output = substr($text, 0, $length = min(strlen($text), $length + $i));
// closing tags
$output2 = (count($tags = array_reverse($tags)) ? '</' . implode('></', $tags) . '>' : '');
// Find last space or HTML tag (solving problem with last space in HTML tag eg. <span class="new">)
$pos = (int)end(end(preg_split('/<.*>| /', $output, -1, PREG_SPLIT_OFFSET_CAPTURE)));
// Append closing tags to output
$output.=$output2;
// Get everything until last space
$one = substr($output, 0, $pos);
// Get the rest
$two = substr($output, $pos, (strlen($output) - $pos));
// Extract all tags from the last bit
preg_match_all('/<(.*?)>/s', $two, $tags);
// Add suffix if needed
if (strlen($text) > $length) { $one .= $suffix; }
// Re-attach tags
$output = $one . implode($tags[0]);
//added to remove unnecessary closure
$output = str_replace('</!-->','',$output);
return $output;
}
function kodau($str)
{
$str = preg_replace("/(à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ)/", 'a', $str);
$str = preg_replace("/(è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ)/", 'e', $str);
$str = preg_replace("/(ì|í|ị|ỉ|ĩ)/", 'i', $str);
$str = preg_replace("/(ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ)/", 'o', $str);
$str = preg_replace("/(ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ)/", 'u', $str);
$str = preg_replace("/(ỳ|ý|ỵ|ỷ|ỹ)/", 'y', $str);
$str = preg_replace("/(đ)/", 'd', $str);
$str = preg_replace("/(À|Á|Ạ|Ả|Ã|Â|Ầ|Ấ|Ậ|Ẩ|Ẫ|Ă|Ằ|Ắ|Ặ|Ẳ|Ẵ)/", 'A', $str);
$str = preg_replace("/(È|É|Ẹ|Ẻ|Ẽ|Ê|Ề|Ế|Ệ|Ể|Ễ)/", 'E', $str);
$str = preg_replace("/(Ì|Í|Ị|Ỉ|Ĩ)/", 'I', $str);
$str = preg_replace("/(Ò|Ó|Ọ|Ỏ|Õ|Ô|Ồ|Ố|Ộ|Ổ|Ỗ|Ơ|Ờ|Ớ|Ợ|Ở|Ỡ)/", 'O', $str);
$str = preg_replace("/(Ù|Ú|Ụ|Ủ|Ũ|Ư|Ừ|Ứ|Ự|Ử|Ữ)/", 'U', $str);
$str = preg_replace("/(Ỳ|Ý|Ỵ|Ỷ|Ỹ)/", 'Y', $str);
$str = preg_replace("/(Đ)/", 'D', $str);
/*$str = preg_replace("/( )/", '-', $str);
$str = preg_replace("/(\'|\"|`|&|,|\.|\?)/", '', $str);
$str = preg_replace("/(---|--)/", '-', $str);
$pattern = '/([^a-z0-9\-\._])/i';
$str = preg_replace($pattern, '', $str);*/
$str = strtolower($str);
return $str;
}
function alias($str)
{
$str = preg_replace("/(à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ)/", 'a', $str);
$str = preg_replace("/(è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ)/", 'e', $str);
$str = preg_replace("/(ì|í|ị|ỉ|ĩ)/", 'i', $str);
$str = preg_replace("/(ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ)/", 'o', $str);
$str = preg_replace("/(ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ)/", 'u', $str);
$str = preg_replace("/(ỳ|ý|ỵ|ỷ|ỹ)/", 'y', $str);
$str = preg_replace("/(đ)/", 'd', $str);
$str = preg_replace("/(À|Á|Ạ|Ả|Ã|Â|Ầ|Ấ|Ậ|Ẩ|Ẫ|Ă|Ằ|Ắ|Ặ|Ẳ|Ẵ)/", 'A', $str);
$str = preg_replace("/(È|É|Ẹ|Ẻ|Ẽ|Ê|Ề|Ế|Ệ|Ể|Ễ)/", 'E', $str);
$str = preg_replace("/(Ì|Í|Ị|Ỉ|Ĩ)/", 'I', $str);
$str = preg_replace("/(Ò|Ó|Ọ|Ỏ|Õ|Ô|Ồ|Ố|Ộ|Ổ|Ỗ|Ơ|Ờ|Ớ|Ợ|Ở|Ỡ)/", 'O', $str);
$str = preg_replace("/(Ù|Ú|Ụ|Ủ|Ũ|Ư|Ừ|Ứ|Ự|Ử|Ữ)/", 'U', $str);
$str = preg_replace("/(Ỳ|Ý|Ỵ|Ỷ|Ỹ)/", 'Y', $str);
$str = preg_replace("/(Đ)/", 'D', $str);
$str = preg_replace("/( )/", '-', $str);
$str = preg_replace("/(\'|\"|`|&|,|\.|\?)/", '', $str);
$str = preg_replace("/(---|--)/", '-', $str);
$pattern = '/([^a-z0-9\-\._])/i';
$str = preg_replace($pattern, '', $str);
$str = strtolower($str);
return $str;
}
function get_id_from_alias($url)
{
$str_id = end(explode('-',$url));
$pos = strpos($str_id,'.html');
if($pos===false){
$id=0;
}else{
$id = (int)substr($str_id,0,$pos);
}
return $id;
}
function get_username($email)
{
$str = explode('@', $email) ;
if(isset($str[0]))
return $str[0];
else
return $email;
}
if ( ! function_exists('base_url_site'))
{
function base_url_site()
{
$CI =& get_instance();
return $CI->config->slash_item('base_url_site');
}
}
function rand_string($size){
$string = "aAbBcCdDeEeFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVmWxXzYyZ";
$rand_str = "";
for ($i=0; $i<$size; $i++)
{
$rand_str .= substr($string, rand(0, strlen($string)-1), 1);
}
return $rand_str;
}
function encrypt($str){
for($i = 0; $i <2; $i ++){
$str = base64_encode(base64_encode($str));
}
$str=rand_string(5).$str;
return $str;
}
function decrypt($str){
$str=substr($str,5,strlen($str));
for($i = 0; $i < 2; $i ++){
$str = base64_decode(base64_decode($str));
}
return $str;
}
function random_string( $length ) {
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
return substr(str_shuffle($chars),0,$length);
}
function searchBar($class=array(),$option,$url_search)
{
$CI =& get_instance();
$search_bar = isset($class['search_bar'])?$class['search_bar']:'search_bar';
$key_search = isset($class['key_search'])?$class['key_search']:'key_search';
$field_search = isset($class['field_search'])?$class['field_search']:'field_search';
$btn_search = isset($class['btn_search'])?$class['btn_search']:'btn_search';
$html_search = '<div class="'.$search_bar.'">';
$html_search .= '<input onkeyup="auto_search(\''.$url_search.'\')" class="'.$key_search.'" name="key_search" id="key_search" type="text" value="'.($CI->session->userdata('key_search')?$CI->session->userdata('key_search'):'').'"/> ';
$html_search .= '<select class="'.$field_search.'" name="field_search" id="field_search">';
foreach($option as $key=>$value){
$html_search .= '<option '.($CI->session->userdata('field_search')==$key?'selected':'').' value="'.$key.'">'.$value.'</option>';
}
$html_search .= '</select> ';
//$html_search .= ' <input class="'.$btn_search.'" name="btn_search" id="btn_search" type="submit" value="Search"/>';
$html_search .= '</div>';
return $html_search;
}
function split_ip($list_ip='')
{
$str = '';
if(empty($list_ip)) return $str;
$arr = explode(",",$list_ip);
foreach ($arr as $a) :
$str .= empty($str)? '<a target="_blank" href="http://vi.geoipseek.com/?q='.$a.'&x=0&y=0">'.$a.'</a>' : ' , <a target="_blank" href="http://vi.geoipseek.com/?q='.$a.'&x=0&y=0">'.$a.'</a>'; //trit($a);
endforeach ;
return $str;
}
?>