| Server IP : 103.48.194.25 / Your IP : 216.73.217.33 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/libraries/ |
Upload File : |
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
class string_library
{
function stringchange($str)
{
$str = strip_tags($str);
$str = mb_strtolower($str,'utf-8');
$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 = str_replace("_","",$str);
$str = str_replace("?","",$str);
$str = str_replace('"',"",$str);
$str = str_replace(")","",$str);
$str = str_replace("/","",$str);
$str = str_replace("%","",$str);
$str = str_replace("&","",$str);
$str = str_replace("–","",$str);
$str = str_replace("_","",$str);
$str = str_replace(".","",$str);
$str = str_replace(",","",$str);
$str = str_replace("-","",$str);
$str = str_replace("(","",$str);
$str = str_replace("!","",$str);
$str = str_replace(" ","-",$str);
$str = str_replace("----","-",$str);
$str = str_replace("---","-",$str);
$str = str_replace("--","-",$str);
$str = preg_replace(array('/[^a-zA-Z0-9 -]/'), array(''), $str) ;
return $str;
}
function changeImgTamtay($value)
{
$value = str_replace("http://img.tamtay.vn/files/", "", $value);
$value = str_replace("_resize.", "_thumb.", $value);
$value = str_replace(".", "_thumb.", $value);
$value = str_replace("_thumb_thumb", "_thumb", $value);
return $value;
}
// Hàm chuyen ngay
function chuyenngay($ngayhientai,$songay)
{
$my_time = strtotime ($ngayhientai); //converts date string to UNIX timestamp
$timestamp = $my_time + ($songay * 86400); //calculates # of days passed ($num_days) * # seconds in a day (86400)
$return_date = date("Y-m-d H:i:s",$timestamp); //puts the UNIX timestamp back into string format
return $return_date;//exit function and return string
}
// Ham cat chu
function catchu($value, $length)
{
if($value!=''){
if(is_array($value)) list($string, $match_to) = $value;
else { $string = $value; $match_to = $value{0}; }
$match_start = stristr($string, $match_to);
$match_compute = strlen($string) - strlen($match_start);
if (strlen($string) > $length)
{
if ($match_compute < ($length - strlen($match_to)))
{
$pre_string = substr($string, 0, $length);
$pos_end = strrpos($pre_string, " ");
if($pos_end === false) $string = $pre_string."...";
else $string = substr($pre_string, 0, $pos_end)."...";
}
else if ($match_compute > (strlen($string) - ($length - strlen($match_to))))
{
$pre_string = substr($string, (strlen($string) - ($length - strlen($match_to))));
$pos_start = strpos($pre_string, " ");
$string = "...".substr($pre_string, $pos_start);
if($pos_start === false) $string = "...".$pre_string;
else $string = "...".substr($pre_string, $pos_start);
}
else
{
$pre_string = substr($string, ($match_compute - round(($length / 3))), $length);
$pos_start = strpos($pre_string, " "); $pos_end = strrpos($pre_string, " ");
$string = "...".substr($pre_string, $pos_start, $pos_end)."...";
if($pos_start === false && $pos_end === false) $string = "...".$pre_string."...";
else $string = "...".substr($pre_string, $pos_start, $pos_end)."...";
}
$match_start = stristr($string, $match_to);
$match_compute = strlen($string) - strlen($match_start);
}
return $string;
}else{
return $string ='';
}
}
// Hàm dinh dang ngay
function format_date($datetime, $format){
return date($format, $this->mysqldatetime_to_timestamp($datetime));
}
function mysqldatetime_to_timestamp($datetime)
{
// function is only applicable for valid MySQL DATETIME (19 characters) and DATE (10 characters)
$l = strlen($datetime);
if(!($l == 10 || $l == 19)) return 0;
$date = $datetime;
$hours = 0;
$minutes = 0;
$seconds = 0;
// DATETIME only
if($l == 19)
{
list($date, $time) = explode(" ", $datetime);
list($hours, $minutes, $seconds) = explode(":", $time);
}
list($year, $month, $day) = explode("-", $date);
return mktime($hours, $minutes, $seconds, $month, $day, $year);
}
/************Loc chu tim kiem****************/
function getkeyword($text)
{
$output = array();
$output2 = array();
$arr = explode('"',$text);
for ($i=0;$i<count($arr);$i++)
{
if ($i%2==0)
{
$output=array_merge($output,explode(" ",$arr[$i]));
}
else $output[] = $arr[$i];
}
foreach($output as $word) if (trim($word)!="") $output2[]=$word;
return $output2;
}
}