���� JFIF �� � ( %"1"%)+...383,7(-.-
![]() Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.20 System : Linux st2.domain.com 3.10.0-1127.10.1.el7.x86_64 #1 SMP Wed Jun 3 14:28:03 UTC 2020 x86_64 User : apache ( 48) PHP Version : 7.4.20 Disable Function : NONE Directory : /var/www/html/admin.adimi/lib/ |
<?php class FUNC { var $textcount = 0; function show_alert($text,$type='error'){ if($type=='error'){ $txt_alert = 'toastr.error(\''.$text.'\')'; }else{ $txt_alert = 'toastr.success(\''.$text.'\')'; } return '<script> $(function() { var Toast = Swal.mixin({ toast: true, position: \'top-end\', showConfirmButton: false, timer: 3000 }); '.$txt_alert.' }); </script>'; } function checkMonday($timestamp=''){ if($timestamp==''){ $timestamp=time(); } if(date('D', $timestamp) === 'Mon') { return 1; }else{ return 0; } } function yes_no ( $bool,$t_name ){ if ($bool == 1 ){ $result = "Yes <input type='radio' name='{$t_name}' value='1' checked> <input type='radio' name='{$t_name}' value='0'> No"; }else{ $result = "Yes <input type='radio' name='{$t_name}' value='1' id='green'> <input type='radio' name='{$t_name}' value='0' checked id='red'> No"; } return $result; } function makebox ( $bool,$t_name ){ if ($bool == 1 ){ $result = "<input type='checkbox' name='{$t_name}[]' value='1' checked>"; }else{ $result = "<input type='checkbox' name='{$t_name}[]' value='0'>"; } return $result; } function checkEmail($input) { return (!eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$", $input))?"":$input; } function checkURL($input) { if(!eregi("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", $input)) { $input = (!eregi("(www.+\\..)", $input))?(""):("http://".$input); } return $input; } //uncovert (decode html code to textarea ) function unconvert($txt="", $code=1, $html=0) { $txt = str_replace( "<br>" , "\n", $txt ); $txt = str_replace( "<br />", "\n", $txt ); return trim(stripslashes($txt)); } //end uncovert function load_lang($langfile) { global $langArray; if(!empty($langfile)){ require ROOT_PATH."lang/".$langfile.".php"; }else{ return; } if(!empty($lang)){ foreach ($lang as $k => $v) { $langArray[$k] = stripslashes(html_entity_decode($v)); } } unset($lang); return $langArray; } function get_input() { global $_GET, $_POST, $REQUEST_METHOD, $REMOTE_ADDR, $HTTP_PROXY_USER, $HTTP_X_FORWARDED_FOR; $return = array(); if( is_array($_GET) ) { foreach ($_GET as $k=>$v){ if ( $k == 'INFO' ) { continue; } if( is_array($_GET[$k]) ) { foreach ($_GET[$k] as $k2=>$v2){ $return[$k][ $this->clean_key($k2) ] = $this->clean_value($v2); } } else { $return[$k] = $this->clean_value($v); } } } // Overwrite GET data with post data if( is_array($_POST) ) { foreach ($_POST as $k=>$v){ if ( is_array($_POST[$k]) ) { foreach ($_POST[$k] as $k2=>$v2){ $return[$k][ $this->clean_key($k2) ] = $this->clean_value($v2); } } else { $return[$k] = $this->clean_value($v); } } } //---------------------------------------- // Sort out the accessing IP // (Thanks to Cosmos and schickb) //---------------------------------------- $addrs = array(); foreach( array_reverse( explode( ',', $HTTP_X_FORWARDED_FOR ) ) as $x_f ) { $x_f = trim($x_f); if ( preg_match( '/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $x_f ) ) { $addrs[] = $x_f; } } $addrs[] = $_SERVER['REMOTE_ADDR']; $addrs[] = $HTTP_PROXY_USER; $addrs[] = $REMOTE_ADDR; $return['IP_ADDRESS'] = $this->select_var( $addrs ); // Make sure we take a valid IP address $return['IP_ADDRESS'] = preg_replace( "/^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/", "\\1.\\2.\\3.\\4", $return['IP_ADDRESS'] ); $return['request_method'] = ( $_SERVER['REQUEST_METHOD'] != "" ) ? strtolower($_SERVER['REQUEST_METHOD']) : strtolower($REQUEST_METHOD); return $return; } /*------------------------------------------------------------------------- */ // Key Cleaner - ensures no funny business with form elements /*------------------------------------------------------------------------- */ function clean_key($key) { if ($key == "") { return ""; } $key = preg_replace( "/\.\./" , "" , $key ); $key = preg_replace( "/\_\_(.+?)\_\_/" , "" , $key ); $key = preg_replace( "/^([\w\.\-\_]+)$/", "$1", $key ); return $key; } function clean_string($string){ $kytu_loaibo = array("?","&",",","/",".","!","@","#","$","%","//",":","\"","\\","'","$","^","(",")","\"","=","_","__"); $kytu_thaythe= array(" "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "); $xuat = str_replace($kytu_loaibo,$kytu_thaythe,$string); //$outstr = $this->clean_value($outstr); return $xuat; } function clean_nhaydon($string){ $kytu_loaibo = array("'"); $kytu_thaythe= array("``"); $xuat = str_replace($kytu_loaibo,$kytu_thaythe,$string); //$outstr = $this->clean_value($outstr); return $xuat; } function convert_vi_to_en($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); return $str; } function bodau_normal2($str) { $chuCoDau=array('à','á','ạ','ả','ã','â','ầ','ấ','ậ','ẩ','ẫ','ă', 'ằ','ắ','ặ','ẳ','ẵ','è','é','ẹ','ẻ','ẽ','ê','ề' ,'ế','ệ','ể','ễ', 'ì','í','ị','ỉ','ĩ', 'ò','ó','ọ','ỏ','õ','ô','ồ','ố','ộ','ổ','ỗ','ơ' ,'ờ','ớ','ợ','ở','ỡ', 'ù','ú','ụ','ủ','ũ','ư','ừ','ứ','ự','ử','ữ', 'ỳ','ý','ỵ','ỷ','ỹ', 'đ', 'À','Á','Ạ','Ả','Ã','Â','Ầ','Ấ','Ậ','Ẩ','Ẫ','Ă' ,'Ằ','Ắ','Ặ','Ẳ','Ẵ', 'È','É','Ẹ','Ẻ','Ẽ','Ê','Ề','Ế','Ệ','Ể','Ễ', 'Ì','Í','Ị','Ỉ','Ĩ', 'Ò','Ó','Ọ','Ỏ','Õ','Ô','Ồ','Ố','Ộ','Ổ','Ỗ','Ơ' ,'Ờ','Ớ','Ợ','Ở','Ỡ', 'Ù','Ú','Ụ','Ủ','Ũ','Ư','Ừ','Ứ','Ự','Ử','Ữ', 'Ỳ','Ý','Ỵ','Ỷ','Ỹ'); $chuKoDau=array('a','a','a','a','a','a','a','a','a','a','a' ,'a','a','a','a','a','a', 'e','e','e','e','e','e','e','e','e','e','e', 'i','i','i','i','i', 'o','o','o','o','o','o','o','o','o','o','o','o' ,'o','o','o','o','o', 'u','u','u','u','u','u','u','u','u','u','u', 'y','y','y','y','y', 'd', 'A','A','A','A','A','A','A','A','A','A','A','A' ,'A','A','A','A','A', 'E','E','E','E','E','E','E','E','E','E','E', 'I','I','I','I','I', 'O','O','O','O','O','O','O','O','O','O','O','O' ,'O','O','O','O','O', 'U','U','U','U','U','U','U','U','U','U','U', 'Y','Y','Y','Y','Y'); $outstr = str_replace($chuCoDau,$chuKoDau,$str); return $outstr; } function bodau_normal($str) { $chuCoDau=array("à","á","ạ","ả","ã","â","ầ","ấ","ậ","ẩ","ẫ","ă", "ằ","ắ","ặ","ẳ","ẵ","è","é","ẹ","ẻ","ẽ","ê","ề" ,"ế","ệ","ể","ễ", "ì","í","ị","ỉ","ĩ", "ò","ó","ọ","ỏ","õ","ô","ồ","ố","ộ","ổ","ỗ","ơ" ,"ờ","ớ","ợ","ở","ỡ", "ù","ú","ụ","ủ","ũ","ư","ừ","ứ","ự","ử","ữ", "ỳ","ý","ỵ","ỷ","ỹ", "đ", "À","Á","Ạ","Ả","Ã","Â","Ầ","Ấ","Ậ","Ẩ","Ẫ","Ă" ,"Ằ","Ắ","Ặ","Ẳ","Ẵ", "È","É","Ẹ","Ẻ","Ẽ","Ê","Ề","Ế","Ệ","Ể","Ễ", "Ì","Í","Ị","Ỉ","Ĩ", "Ò","Ó","Ọ","Ỏ","Õ","Ô","Ồ","Ố","Ộ","Ổ","Ỗ","Ơ" ,"Ờ","Ớ","Ợ","Ở","Ỡ", "Ù","Ú","Ụ","Ủ","Ũ","Ư","Ừ","Ứ","Ự","Ử","Ữ", "Ỳ","Ý","Ỵ","Ỷ","Ỹ"); $chuKoDau=array("a","a","a","a","a","a","a","a","a","a","a" ,"a","a","a","a","a","a", "e","e","e","e","e","e","e","e","e","e","e", "i","i","i","i","i", "o","o","o","o","o","o","o","o","o","o","o","o" ,"o","o","o","o","o", "u","u","u","u","u","u","u","u","u","u","u", "y","y","y","y","y", "d", "A","A","A","A","A","A","A","A","A","A","A","A" ,"A","A","A","A","A", "E","E","E","E","E","E","E","E","E","E","E", "I","I","I","I","I", "O","O","O","O","O","O","O","O","O","O","O","O" ,"O","O","O","O","O", "U","U","U","U","U","U","U","U","U","U","U", "Y","Y","Y","Y","Y"); $outstr = str_replace($chuCoDau,$chuKoDau,$str); $outstr = strtolower(trim($outstr)); //$outstr = $this->clean_value($outstr); return $outstr; } function bodau($str) { $chuCoDau=array("à","á","ạ","ả","ã","â","ầ","ấ","ậ","ẩ","ẫ","ă", "ằ","ắ","ặ","ẳ","ẵ","è","é","ẹ","ẻ","ẽ","ê","ề" ,"ế","ệ","ể","ễ", "ì","í","ị","ỉ","ĩ", "ò","ó","ọ","ỏ","õ","ô","ồ","ố","ộ","ổ","ỗ","ơ" ,"ờ","ớ","ợ","ở","ỡ", "ù","ú","ụ","ủ","ũ","ư","ừ","ứ","ự","ử","ữ", "ỳ","ý","ỵ","ỷ","ỹ", "đ", "À","Á","Ạ","Ả","Ã","Â","Ầ","Ấ","Ậ","Ẩ","Ẫ","Ă" ,"Ằ","Ắ","Ặ","Ẳ","Ẵ", "È","É","Ẹ","Ẻ","Ẽ","Ê","Ề","Ế","Ệ","Ể","Ễ", "Ì","Í","Ị","Ỉ","Ĩ", "Ò","Ó","Ọ","Ỏ","Õ","Ô","Ồ","Ố","Ộ","Ổ","Ỗ","Ơ" ,"Ờ","Ớ","Ợ","Ở","Ỡ", "Ù","Ú","Ụ","Ủ","Ũ","Ư","Ừ","Ứ","Ự","Ử","Ữ", "Ỳ","Ý","Ỵ","Ỷ","Ỹ", "Đ","?","&",",","/",".","!","@","#","$","%","//",":","\"","\\","'","$","^","(",")","\"","=","_","__","\"","“","”","-"," - ","|","[","]"); $chuKoDau=array("a","a","a","a","a","a","a","a","a","a","a" ,"a","a","a","a","a","a", "e","e","e","e","e","e","e","e","e","e","e", "i","i","i","i","i", "o","o","o","o","o","o","o","o","o","o","o","o" ,"o","o","o","o","o", "u","u","u","u","u","u","u","u","u","u","u", "y","y","y","y","y", "d", "A","A","A","A","A","A","A","A","A","A","A","A" ,"A","A","A","A","A", "E","E","E","E","E","E","E","E","E","E","E", "I","I","I","I","I", "O","O","O","O","O","O","O","O","O","O","O","O" ,"O","O","O","O","O", "U","U","U","U","U","U","U","U","U","U","U", "Y","Y","Y","Y","Y", "D","","","","","","","","","","","","","","","","","","","","","","","","","","","",'-','','',''); $outstr = str_replace($chuCoDau,$chuKoDau,$str); $outstr = strtolower(trim($outstr)); //$outstr = $this->clean_value($outstr); return $outstr; } function format_string($str2){ $str = $this->bodau($str2); $str = preg_replace('/^[^\p{L}\p{Nd}]+/',' ', $str); $str = trim($str); $str = preg_replace('/\s+/', ' ', $str); $str = preg_replace('/\s+/', '-', $str); return empty($str)?str_replace(' ','-',$str2):strtolower($str); } function clean_value($val) { if ($val == "") { return ""; } $val = str_replace( " ", " ", $val ); $val = str_replace( chr(0xCA), "", $val ); //Remove sneaky spaces $val = str_replace( "&" , "&" , $val ); $val = str_replace( "<!--" , "<!--" , $val ); $val = str_replace( "-->" , "-->" , $val ); $val = preg_replace( "/<script/i" , "<script" , $val ); $val = str_replace( ">" , ">" , $val ); $val = str_replace( "<" , "<" , $val ); $val = str_replace( "\"" , """ , $val ); //$val = preg_replace( "/\n/" , "<br>" , $val ); // Convert literal newlines $val = preg_replace( "/\\\$/" , "$" , $val ); $val = preg_replace( "/\r/" , "" , $val ); // Remove literal carriage returns $val = str_replace( "!" , "!" , $val ); $val = str_replace( "'" , "'" , $val ); // IMPORTANT: It helps to increase sql query safety. // Ensure unicode chars are OK $val = preg_replace("/&#([0-9]+);/s", "&#\\1;", $val ); // Swop user inputted backslashes //$val = preg_replace( "/\\\(?!&#|\?#)/", "\", $val ); return $val; } function select_var($array) { if ( !is_array($array) ) return -1; ksort($array); $chosen = -1; // Ensure that we return zero if nothing else is available foreach ($array as $k => $v) { if (isset($v)) { $chosen = $v; break; } } return $chosen; } function drop_down_menu($name,$selected,$tablename,$choice_id,$choice_name,$extention="",$sname,$event="") { global $DB; $temp = $DB->query("SELECT $choice_id,$choice_name FROM $tablename $extention LIMIT 1"); $dab =""; if(!$DB->fetch_row ($temp)){ $dab = "disabled=\"disabled\""; } $html = "<select name='$name' id='$name' $dab $event>"; if($sname=="notchoice"){ $sname = "Không chọn(Danh mục root)..."; $html .=" <option value='0'>{$sname}</option>"; } $temp = $DB->query("SELECT $choice_id,$choice_name FROM $tablename $extention"); while ($row=$DB->fetch_row ($temp)){ if ($row[$choice_id]==$selected) $s = "selected"; else $s = ""; $html .=" <option value='{$row[$choice_id]}' {$s} >{$row[$choice_name]}</option>"; } $html .="</select>"; return $html ; } function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } function get_file_extension($file_name) { return substr(strrchr($file_name,'.'),1); } function make_password($number_char='') { if($number_char==''){ $number_char = 8; } $pass = ""; $chars = array( "1","2","3","4","5","6","7","8","9","0", "a","A","b","B","c","C","d","D","e","E","f","F","g","G","h","H","i","I","j","J", "k","K","l","L","m","M","n","N","o","O","p","P","q","Q","r","R","s","S","t","T", "u","U","v","V","w","W","x","X","y","Y","z","Z"); $count = count($chars) - 1; srand((double)microtime()*1000000); for($i = 0; $i < $number_char; $i++) { $pass .= $chars[rand(0, $count)]; } return($pass); } function maketime(){ $today = time(); $tran = array( '1'=>'Thứ hai','2'=>'Thứ ba','3'=>'Thứ tư','4'=>'Thứ năm','5'=>'Thứ sáu','6'=>'Thứ 7','7'=>'Chủ nhật'); $date = $tran[date('w',$today)]; $day['thu'] = $date; $day['day'] = date('d',$today); $day['month'] = date('m',$today); $day['year'] = date('Y',$today); return ($day); } function encode($input) { return strtr(base64_encode($input), '+/=', '-_,'); } function decode($input) { return base64_decode(strtr($input, '-_,', '+/=')); } function lastchar($str){ //$str = 'Ok Y'; return $str[strlen($str)-1]; // $last = "y" } function remove_lastchar($str,$n)/*bo n ky tu cuoi trong chuoi str*/{ $new_str=substr($str,0,(strlen($str)-$n)); return $new_str; } function current_url() { $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == 'on') ? 's' : ''; return 'http'.$s.'://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; } function ope_max($str,$len){ if(strlen($str) < $len){ return $str; }else{ $str = substr($str,0,$len); $a_str = explode(' ',$str); unset($a_str[count($a_str)-1]); $str = implode(' ',$a_str); $str = $str.'...'; return $str; } } function just_number($string){ return preg_replace('/[^0-9]/', '',$string); } // Menu builder function, parentId 0 is the root function buildMenu($parent, $menu) { $html = ""; if (isset($menu['parents'][$parent])) { $html .= "<ul>"; foreach ($menu['parents'][$parent] as $itemId) { if(!isset($menu['parents'][$itemId])) { $html .= "<li><a href='".$menu['items'][$itemId]['ftitle']."'>".$menu['items'][$itemId]['title']."</a></li>"; } if(isset($menu['parents'][$itemId])) { $html .= " <li><a href='".$menu['items'][$itemId]['ftitle']."'>".$menu['items'][$itemId]['title']."</a>"; $html .= $this->buildMenu($itemId, $menu); $html .= "</li>"; } } $html .= "</ul>"; } return $html; } function get_id_youtube($url) { $v = ''; // get video ID from $_GET if (!isset($url)) { return 'Please enter a YouTube video URL.'; } else { $vid = stripslashes($url); $string = $vid; $url = parse_url($string); parse_str($url['query']); } return $v; } function str_encode($data,$pwd) { $x = 0; $a = 0; $j = 0; $Zcrypt = ''; $counter = array(); for ($ii = 0; $ii < 257; $ii++) { $counter[$ii] = ''; } $pwd_length = strlen($pwd); for ($i = 0; $i < 255; $i++) { $key[$i] = ord(substr($pwd, ($i % $pwd_length)+1, 1)); $counter[$i] = $i; } for ($i = 0; $i < 255; $i++) { $x = ($x + $counter[$i] + $key[$i]) % 256; $temp_swap = $counter[$i]; $counter[$i] = $counter[$x]; $counter[$x] = $temp_swap; } for ($i = 0; $i < strlen($data); $i++) { $a = ($a + 1) % 256; $j = ($j + $counter[$a]) % 256; $temp = $counter[$a]; $counter[$a] = $counter[$j]; $counter[$j] = $temp; $k = $counter[(($counter[$a] + $counter[$j]) % 256)]; $Zcipher = ord(substr($data, $i, 1)) ^ $k; $Zcrypt .= chr($Zcipher); } return $Zcrypt; } function hex2bin($hexdata) { $bindata = ''; for ($i=0;$i<strlen($hexdata);$i+=2) { $bindata .= chr(hexdec(substr($hexdata,$i,2))); } return $bindata; } //$encoded = bin2hex(str_encode($txt,$time)); //$decoded = str_encode(hex2bin($encoded),$time); function curl_func($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); $head[] = "Connection: keep-alive"; $head[] = "Keep-Alive: 300"; $head[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7"; $head[] = "Accept-Language: en-us,en;q=0.5"; curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36'); curl_setopt($ch, CURLOPT_HTTPHEADER, $head); //curl_setopt($ch, CURLOPT_REFERER, 'http://www.phimmoi.net'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_TIMEOUT, 60); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); $page = curl_exec($ch); curl_close($ch); return $page; } function get_content_page($url,$referer) { $header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,"; $header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"; $header[] = "Cache-Control: max-age=0"; $header[] = "Connection: keep-alive"; $header[] = "Keep-Alive: 300"; $header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7"; $header[] = "Accept-Language: en-us,en;q=0.5"; $header[] = "Pragma: "; // browsers keep this blank. $process = curl_init($url); curl_setopt($process, CURLOPT_HTTPHEADER, $header); curl_setopt($process, CURLOPT_HEADER, 0); curl_setopt($process, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'); //curl_setopt($process, CURLOPT_COOKIEFILE, dirname(__FILE__).'/'.'cookies_youtube.txt'); //curl_setopt($process, CURLOPT_COOKIEJAR, dirname(__FILE__).'/'.'cookies_youtube.txt'); curl_setopt($process, CURLOPT_REFERER, $referer); curl_setopt($process, CURLOPT_ENCODING, 'gzip,deflate'); //curl_setopt($process,CURLOPT_ENCODING , compression); curl_setopt($process, CURLOPT_TIMEOUT, 20); //if (proxy) curl_setopt($cUrl, CURLOPT_PROXY, 'proxy_ip:proxy_port'); curl_setopt($process, CURLOPT_RETURNTRANSFER, 1); //curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1); $return = curl_exec($process); curl_close($process); return $return; } function alphaID($in, $to_num = false, $pad_up = false, $pass_key = null) { $out = ''; $index = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $base = strlen($index); if ($pass_key !== null) { // Although this function's purpose is to just make the // ID short - and not so much secure, // with this patch by Simon Franz (http://blog.snaky.org/) // you can optionally supply a password to make it harder // to calculate the corresponding numeric ID for ($n = 0; $n < strlen($index); $n++) { $i[] = substr($index, $n, 1); } $pass_hash = hash('sha256',$pass_key); $pass_hash = (strlen($pass_hash) < strlen($index) ? hash('sha512', $pass_key) : $pass_hash); for ($n = 0; $n < strlen($index); $n++) { $p[] = substr($pass_hash, $n, 1); } array_multisort($p, SORT_DESC, $i); $index = implode($i); } if ($to_num) { // Digital number <<-- alphabet letter code $len = strlen($in) - 1; for ($t = $len; $t >= 0; $t--) { $bcp = bcpow($base, $len - $t); $out = $out + strpos($index, substr($in, $t, 1)) * $bcp; } if (is_numeric($pad_up)) { $pad_up--; if ($pad_up > 0) { $out -= pow($base, $pad_up); } } } else { // Digital number -->> alphabet letter code if (is_numeric($pad_up)) { $pad_up--; if ($pad_up > 0) { $in += pow($base, $pad_up); } } for ($t = ($in != 0 ? floor(log($in, $base)) : 0); $t >= 0; $t--) { $bcp = bcpow($base, $t); $a = floor($in / $bcp) % $base; $out = $out . substr($index, $a, 1); $in = $in - ($a * $bcp); } } return $out; /* Running: alphaID(9007199254740989); will return PpQXn7COf and: alphaID('PpQXn7COf', true); will return 9007199254740989 */ } function covtime($youtube_time) { preg_match_all('/(\d+)/',$youtube_time,$parts); // Put in zeros if we have less than 3 numbers. if (count($parts[0]) == 1) { array_unshift($parts[0], "0", "0"); } elseif (count($parts[0]) == 2) { array_unshift($parts[0], "0"); } $sec_init = $parts[0][2]; $seconds = $sec_init%60; $seconds_overflow = floor($sec_init/60); $min_init = $parts[0][1] + $seconds_overflow; $minutes = ($min_init)%60; $minutes_overflow = floor(($min_init)/60); $hours = $parts[0][0] + $minutes_overflow; if($hours != 0) return $hours.':'.$minutes.':'.$seconds; else return $minutes.':'.$seconds; } function encode_html($input) { $temp = ''; $length = strlen($input); for($i = 0; $i < $length; $i++) $temp .= '%' . bin2hex($input[$i]); return $temp; } function getCloud( $data = array(), $minFontSize = 12, $maxFontSize = 40 ) { $minimumCount = min( array_values( $data ) ); $maximumCount = max( array_values( $data ) ); $spread = $maximumCount - $minimumCount; $cloudTags = array(); $spread == 0 && $spread = 1; foreach( $data as $tag => $count ) { $size = $minFontSize + ( $count - $minimumCount ) * ( $maxFontSize - $minFontSize ) / $spread; $cloudTags[] = '<a style="font-size: ' . floor( $size ) . 'px' . '" class="tag_cloud" href="tags/'.$tag . '/" title="' . $tag . '">' . htmlspecialchars( stripslashes( $tag ) ) . '</a>'; } return implode( ", ", $cloudTags ); } function title_text($text){ return trim(strip_tags(str_replace('"','"',html_entity_decode($text)))); } function check_value_array_in_string($headline, $fields) { $field_values = array_values($fields); foreach ($field_values as $field_value) { if (strpos($headline, $field_value) !== false) { return true; // field value found in a string } } return false; // nothing found during the loop } function json_decode_nice($json, $assoc = TRUE){ $json = str_replace(array("\n","\r"),"\\n",$json); $json = preg_replace('/([{,]+)(\s*)([^"]+?)\s*:/','$1"$3":',$json); $json = preg_replace('/(,)\s*}$/','}',$json); return json_decode($json,$assoc); } function iso8601_duration($seconds) { $intervals = array('D' => 60*60*24, 'H' => 60*60, 'M' => 60, 'S' => 1); $pt = 'P'; $result = ''; foreach ($intervals as $tag => $divisor) { $qty = floor($seconds/$divisor); if ( !$qty && $result == '' ) { $pt = 'T'; continue; } $seconds -= $qty * $divisor; $result .= "$qty$tag"; } if ( $result=='' ) $result='0S'; return "$pt$result"; } function get_ip_address() { // check for shared internet/ISP IP if (!empty($_SERVER['HTTP_CLIENT_IP'])) { return $_SERVER['HTTP_CLIENT_IP']; } // check for IPs passing through proxies if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { return $_SERVER['HTTP_X_FORWARDED_FOR']; } if (!empty($_SERVER['HTTP_X_FORWARDED'])) { return $_SERVER['HTTP_X_FORWARDED']; } if (!empty($_SERVER['HTTP_X_CLUSTER_CLIENT_IP'])) { return $_SERVER['HTTP_X_CLUSTER_CLIENT_IP']; } if (!empty($_SERVER['HTTP_FORWARDED_FOR'])) { return $_SERVER['HTTP_FORWARDED_FOR']; } if (!empty($_SERVER['HTTP_FORWARDED'])) { return $_SERVER['HTTP_FORWARDED']; } // return unreliable ip since all else failed return $_SERVER['REMOTE_ADDR']; } function tree_company($parentid,$arr,$sep){ foreach($arr as $key=>$v){ if($v['company_parentid'] == $parentid){ $arr[$key]['company_name'] = $sep.' '.$arr[$key]['company_name']; $arr = $this->tree_company($v['company_id'],$arr,$sep." + "); } } return $arr; } function get_pupil_real_name_flag($p_pupil_real_name){ $arr = explode("(",$p_pupil_real_name); if(sizeof($arr)==2){ return substr($arr[1],0,1); } return ""; } function generate_pupil_order($p_pupil_real_name){ $v_flag = $this->get_pupil_real_name_flag($p_pupil_real_name); $v_pupil_real_name = trim(str_replace("(".$v_flag.")","",$p_pupil_real_name)); while (strpos($v_pupil_real_name," ")!==false) { $v_pupil_real_name = str_replace(" "," ",$v_pupil_real_name); } $arr_pupil_real_name = explode(" ",$v_pupil_real_name); $v_size = sizeof($arr_pupil_real_name); $v_ret_val = ""; for ($i=$v_size-1;$i>=0;$i--){ $v_tmp = strtolower(trim($this->convert_utf8_to_kd_for_order_2($arr_pupil_real_name[$i]))); if(strpos($v_tmp,"-1")){ $v_tmp = str_replace("-1","",$v_tmp); $v_tmp .= "1"; } if(strpos($v_tmp,"-2")){ $v_tmp = str_replace("-2","",$v_tmp); $v_tmp .= "2"; } if(strpos($v_tmp,"-3")){ $v_tmp = str_replace("-3","",$v_tmp); $v_tmp .= "3"; } if(strpos($v_tmp,"-4")){ $v_tmp = str_replace("-4","",$v_tmp); $v_tmp .= "4"; } if(strpos($v_tmp,"-5")){ $v_tmp = str_replace("-5","",$v_tmp); $v_tmp .= "5"; } $v_ret_val .= $v_tmp." "; } return $v_ret_val.$v_flag; } function convert_utf8_to_kd_for_order_2($str){ $arr_sour_char_code=array(); $arr_dest_char_code=array(); $arr_sour_char_code[2]=chr(195).chr(128); $arr_dest_char_code[2]="a-1"; $arr_sour_char_code[1]=chr(195).chr(129); $arr_dest_char_code[1]="a-2"; $arr_sour_char_code[3]=chr(225).chr(186).chr(162); $arr_dest_char_code[3]="a-3"; $arr_sour_char_code[4]=chr(195).chr(131); $arr_dest_char_code[4]="a-4"; $arr_sour_char_code[5]=chr(225).chr(186).chr(160); $arr_dest_char_code[5]="a-5"; $arr_sour_char_code[7]=chr(195).chr(160); $arr_dest_char_code[7]="a-1"; $arr_sour_char_code[6]=chr(195).chr(161); $arr_dest_char_code[6]="a-2"; $arr_sour_char_code[8]=chr(225).chr(186).chr(163); $arr_dest_char_code[8]="a-3"; $arr_sour_char_code[9]=chr(195).chr(163); $arr_dest_char_code[9]="a-4"; $arr_sour_char_code[10]=chr(225).chr(186).chr(161); $arr_dest_char_code[10]="a-5"; $arr_dest_char_code[24]="az"; $arr_sour_char_code[26]=chr(225).chr(186).chr(176); $arr_dest_char_code[26]="az-1"; $arr_sour_char_code[25]=chr(225).chr(186).chr(174); $arr_dest_char_code[25]="az-2"; $arr_sour_char_code[27]=chr(225).chr(186).chr(178); $arr_dest_char_code[27]="az-3"; $arr_sour_char_code[28]=chr(225).chr(186).chr(180); $arr_dest_char_code[28]="az-4"; $arr_sour_char_code[29]=chr(225).chr(186).chr(182); $arr_dest_char_code[29]="az-5"; $arr_sour_char_code[30]=chr(196).chr(131); $arr_dest_char_code[30]="az"; $arr_sour_char_code[32]=chr(225).chr(186).chr(177); $arr_dest_char_code[32]="az-1"; $arr_sour_char_code[31]=chr(225).chr(186).chr(175); $arr_dest_char_code[31]="az-2"; $arr_sour_char_code[33]=chr(225).chr(186).chr(179); $arr_dest_char_code[33]="az-3"; $arr_sour_char_code[34]=chr(225).chr(186).chr(181); $arr_dest_char_code[34]="az-4"; $arr_sour_char_code[35]=chr(225).chr(186).chr(183); $arr_dest_char_code[35]="az-5"; $arr_sour_char_code[11]=chr(195).chr(130); $arr_dest_char_code[11]="azz"; $arr_sour_char_code[13]=chr(225).chr(186).chr(166); $arr_dest_char_code[13]="azz-1"; $arr_sour_char_code[12]=chr(225).chr(186).chr(164); $arr_dest_char_code[12]="azz-2"; $arr_sour_char_code[14]=chr(225).chr(186).chr(168); $arr_dest_char_code[14]="azz-3"; $arr_sour_char_code[15]=chr(225).chr(186).chr(170); $arr_dest_char_code[15]="azz-4"; $arr_sour_char_code[16]=chr(225).chr(186).chr(172); $arr_dest_char_code[16]="azz-5"; $arr_sour_char_code[17]=chr(195).chr(162); $arr_dest_char_code[17]="azz"; $arr_sour_char_code[19]=chr(225).chr(186).chr(167); $arr_dest_char_code[19]="azz-1"; $arr_sour_char_code[18]=chr(225).chr(186).chr(165); $arr_dest_char_code[18]="azz-2"; $arr_sour_char_code[20]=chr(225).chr(186).chr(169); $arr_dest_char_code[20]="azz-3"; $arr_sour_char_code[21]=chr(225).chr(186).chr(171); $arr_dest_char_code[21]="azz-4"; $arr_sour_char_code[22]=chr(225).chr(186).chr(171); $arr_dest_char_code[22]="azz-4"; $arr_sour_char_code[23]=chr(225).chr(186).chr(173); $arr_dest_char_code[23]="azz-5"; $arr_sour_char_code[24]=chr(196).chr(130); $arr_sour_char_code[37]=chr(195).chr(136); $arr_dest_char_code[37]="e-1"; $arr_sour_char_code[36]=chr(195).chr(137); $arr_dest_char_code[36]="e-2"; $arr_sour_char_code[38]=chr(225).chr(186).chr(186); $arr_dest_char_code[38]="e-3"; $arr_sour_char_code[39]=chr(225).chr(186).chr(188); $arr_dest_char_code[39]="e-4"; $arr_sour_char_code[40]=chr(225).chr(186).chr(184); $arr_dest_char_code[40]="e-5"; $arr_sour_char_code[42]=chr(195).chr(168); $arr_dest_char_code[42]="e-1"; $arr_sour_char_code[41]=chr(195).chr(169); $arr_dest_char_code[41]="e-2"; $arr_sour_char_code[43]=chr(225).chr(186).chr(187); $arr_dest_char_code[43]="e-3"; $arr_sour_char_code[44]=chr(225).chr(186).chr(189); $arr_dest_char_code[44]="e-4"; $arr_sour_char_code[45]=chr(225).chr(186).chr(185); $arr_dest_char_code[45]="e-5"; $arr_sour_char_code[46]=chr(195).chr(138); $arr_dest_char_code[46]="ez"; $arr_sour_char_code[48]=chr(225).chr(187).chr(128); $arr_dest_char_code[48]="ez-1"; $arr_sour_char_code[47]=chr(225).chr(186).chr(190); $arr_dest_char_code[47]="ez-2"; $arr_sour_char_code[49]=chr(225).chr(187).chr(130); $arr_dest_char_code[49]="ez-3"; $arr_sour_char_code[50]=chr(225).chr(187).chr(132); $arr_dest_char_code[50]="ez-4"; $arr_sour_char_code[51]=chr(225).chr(187).chr(134); $arr_dest_char_code[51]="ez-5"; $arr_sour_char_code[52]=chr(195).chr(170); $arr_dest_char_code[52]="ez"; $arr_sour_char_code[54]=chr(225).chr(187).chr(129); $arr_dest_char_code[54]="ez-1"; $arr_sour_char_code[53]=chr(225).chr(186).chr(191); $arr_dest_char_code[53]="ez-2"; $arr_sour_char_code[55]=chr(225).chr(187).chr(131); $arr_dest_char_code[55]="ez-3"; $arr_sour_char_code[56]=chr(225).chr(187).chr(133); $arr_dest_char_code[56]="ez-4"; $arr_sour_char_code[57]=chr(225).chr(187).chr(135); $arr_dest_char_code[57]="ez-5"; $arr_dest_char_code[71]="o-1"; $arr_sour_char_code[70]=chr(195).chr(179); $arr_dest_char_code[70]="o-2"; $arr_sour_char_code[72]=chr(225).chr(187).chr(143); $arr_dest_char_code[72]="o-3"; $arr_sour_char_code[73]=chr(195).chr(181); $arr_dest_char_code[73]="o-4"; $arr_sour_char_code[74]=chr(225).chr(187).chr(141); $arr_dest_char_code[74]="o-5"; $arr_sour_char_code[76]=chr(195).chr(146); $arr_dest_char_code[76]="o-1"; $arr_sour_char_code[75]=chr(195).chr(147); $arr_dest_char_code[75]="o-2"; $arr_sour_char_code[77]=chr(225).chr(187).chr(142); $arr_dest_char_code[77]="o-3"; $arr_sour_char_code[78]=chr(195).chr(149); $arr_dest_char_code[78]="o-4"; $arr_sour_char_code[79]=chr(225).chr(187).chr(140); $arr_dest_char_code[79]="o-5"; $arr_sour_char_code[58]=chr(195).chr(180); $arr_dest_char_code[58]="oz"; $arr_sour_char_code[59]=chr(225).chr(187).chr(145); $arr_dest_char_code[59]="oz-1"; $arr_sour_char_code[60]=chr(225).chr(187).chr(147); $arr_dest_char_code[60]="oz-2"; $arr_sour_char_code[61]=chr(225).chr(187).chr(149); $arr_dest_char_code[61]="oz-3"; $arr_sour_char_code[62]=chr(225).chr(187).chr(151); $arr_dest_char_code[62]="oz-4"; $arr_sour_char_code[63]=chr(225).chr(187).chr(153); $arr_dest_char_code[63]="oz-5"; $arr_sour_char_code[64]=chr(195).chr(148); $arr_dest_char_code[64]="oz"; $arr_sour_char_code[66]=chr(225).chr(187).chr(146); $arr_dest_char_code[66]="oz-1"; $arr_sour_char_code[65]=chr(225).chr(187).chr(144); $arr_dest_char_code[65]="oz-2"; $arr_sour_char_code[67]=chr(225).chr(187).chr(148); $arr_dest_char_code[67]="oz-3"; $arr_sour_char_code[68]=chr(225).chr(187).chr(150); $arr_dest_char_code[68]="oz-4"; $arr_sour_char_code[69]=chr(225).chr(187).chr(152); $arr_dest_char_code[69]="oz-5"; $arr_sour_char_code[71]=chr(195).chr(178); $arr_sour_char_code[126]=chr(198).chr(161); $arr_dest_char_code[126]="ozz"; $arr_sour_char_code[127]=chr(225).chr(187).chr(155); $arr_dest_char_code[127]="ozz-1"; $arr_sour_char_code[128]=chr(225).chr(187).chr(157); $arr_dest_char_code[128]="ozz-2"; $arr_sour_char_code[129]=chr(225).chr(187).chr(159); $arr_dest_char_code[129]="ozz-3"; $arr_sour_char_code[130]=chr(225).chr(187).chr(161); $arr_dest_char_code[130]="ozz-4"; $arr_sour_char_code[131]=chr(225).chr(187).chr(163); $arr_dest_char_code[131]="ozz-5"; $arr_sour_char_code[132]=chr(198).chr(160); $arr_dest_char_code[132]="ozz"; $arr_sour_char_code[133]=chr(225).chr(187).chr(156); $arr_dest_char_code[133]="ozz-1"; $arr_sour_char_code[134]=chr(225).chr(187).chr(154); $arr_dest_char_code[134]="ozz-2"; $arr_sour_char_code[135]=chr(225).chr(187).chr(158); $arr_dest_char_code[135]="ozz-3"; $arr_sour_char_code[136]=chr(225).chr(187).chr(160); $arr_dest_char_code[136]="ozz-4"; $arr_sour_char_code[137]=chr(225).chr(187).chr(162); $arr_dest_char_code[137]="ozz-5"; $arr_sour_char_code[81]=chr(195).chr(140); $arr_dest_char_code[81]="i-1"; $arr_sour_char_code[80]=chr(195).chr(141); $arr_dest_char_code[80]="i-2"; $arr_sour_char_code[82]=chr(225).chr(187).chr(136); $arr_dest_char_code[82]="i-3"; $arr_sour_char_code[83]=chr(196).chr(168); $arr_dest_char_code[83]="i-4"; $arr_sour_char_code[84]=chr(225).chr(187).chr(138); $arr_dest_char_code[84]="i-5"; $arr_sour_char_code[86]=chr(195).chr(172); $arr_dest_char_code[86]="i-1"; $arr_sour_char_code[85]=chr(195).chr(173); $arr_dest_char_code[85]="i-2"; $arr_sour_char_code[87]=chr(225).chr(187).chr(137); $arr_dest_char_code[87]="i-3"; $arr_sour_char_code[88]=chr(196).chr(169); $arr_dest_char_code[88]="i-4"; $arr_sour_char_code[89]=chr(225).chr(187).chr(139); $arr_dest_char_code[89]="i-5"; $arr_sour_char_code[91]=chr(195).chr(185); $arr_dest_char_code[91]="u-1"; $arr_sour_char_code[90]=chr(195).chr(186); $arr_dest_char_code[90]="u-2"; $arr_sour_char_code[92]=chr(225).chr(187).chr(167); $arr_dest_char_code[92]="u-3"; $arr_sour_char_code[93]=chr(197).chr(169); $arr_dest_char_code[93]="u-4"; $arr_sour_char_code[94]=chr(225).chr(187).chr(165); $arr_dest_char_code[94]="u-5"; $arr_sour_char_code[96]=chr(195).chr(153); $arr_dest_char_code[96]="u-1"; $arr_sour_char_code[95]=chr(195).chr(154); $arr_dest_char_code[95]="u-2"; $arr_sour_char_code[97]=chr(225).chr(187).chr(166); $arr_dest_char_code[97]="u-3"; $arr_sour_char_code[98]=chr(197).chr(168); $arr_dest_char_code[98]="u-4"; $arr_sour_char_code[99]=chr(197).chr(168); $arr_dest_char_code[99]="u-4"; $arr_sour_char_code[100]=chr(225).chr(187).chr(164); $arr_dest_char_code[100]="u-5"; $arr_sour_char_code[101]=chr(198).chr(176); $arr_dest_char_code[101]="uz"; $arr_sour_char_code[103]=chr(225).chr(187).chr(171); $arr_dest_char_code[103]="uz-1"; $arr_sour_char_code[102]=chr(225).chr(187).chr(169); $arr_dest_char_code[102]="uz-2"; $arr_sour_char_code[104]=chr(225).chr(187).chr(173); $arr_dest_char_code[104]="uz-3"; $arr_sour_char_code[105]=chr(225).chr(187).chr(175); $arr_dest_char_code[105]="uz-4"; $arr_sour_char_code[106]=chr(225).chr(187).chr(177); $arr_dest_char_code[106]="uz-5"; $arr_sour_char_code[107]=chr(198).chr(175); $arr_dest_char_code[107]="uz"; $arr_sour_char_code[109]=chr(225).chr(187).chr(170); $arr_dest_char_code[109]="uz-1"; $arr_sour_char_code[108]=chr(225).chr(187).chr(168); $arr_dest_char_code[108]="uz-2"; $arr_sour_char_code[110]=chr(225).chr(187).chr(172); $arr_dest_char_code[110]="uz-3"; $arr_sour_char_code[111]=chr(225).chr(187).chr(172); $arr_dest_char_code[111]="uz-4"; $arr_sour_char_code[112]=chr(225).chr(187).chr(174); $arr_dest_char_code[112]="uz-4"; $arr_sour_char_code[113]=chr(225).chr(187).chr(176); $arr_dest_char_code[113]="uz-5"; $arr_sour_char_code[115]=chr(225).chr(187).chr(178); $arr_dest_char_code[115]="y-1"; $arr_sour_char_code[114]=chr(195).chr(157); $arr_dest_char_code[114]="y-2"; $arr_sour_char_code[116]=chr(225).chr(187).chr(182); $arr_dest_char_code[116]="y-3"; $arr_sour_char_code[117]=chr(225).chr(187).chr(184); $arr_dest_char_code[117]="y-4"; $arr_sour_char_code[118]=chr(225).chr(187).chr(180); $arr_dest_char_code[118]="y-5"; $arr_sour_char_code[120]=chr(225).chr(187).chr(179); $arr_dest_char_code[120]="y-1"; $arr_sour_char_code[119]=chr(195).chr(189); $arr_dest_char_code[119]="y-2"; $arr_sour_char_code[121]=chr(225).chr(187).chr(183); $arr_dest_char_code[121]="y-3"; $arr_sour_char_code[122]=chr(225).chr(187).chr(185); $arr_dest_char_code[122]="y-4"; $arr_sour_char_code[123]=chr(225).chr(187).chr(181); $arr_dest_char_code[123]="y-5"; $arr_sour_char_code[124]=chr(196).chr(144); $arr_dest_char_code[124]="dz"; $arr_sour_char_code[125]=chr(196).chr(145); $arr_dest_char_code[125]="dz"; for ($i=1;$i<138; $i++){ $str = str_replace($arr_sour_char_code[$i],$arr_dest_char_code[$i],$str); } return($str); } function convert_number_to_words($amount) { if($amount <=0) { return $textnumber="Tiền phải là số nguyên dương lớn hơn số 0"; } $Text=array("không", "một", "hai", "ba", "bốn", "năm", "sáu", "bảy", "tám", "chín"); $TextLuythua =array("","nghìn", "triệu", "tỷ", "ngàn tỷ", "triệu tỷ", "tỷ tỷ"); $textnumber = ""; $length = strlen($amount); for ($i = 0; $i < $length; $i++) $unread[$i] = 0; for ($i = 0; $i < $length; $i++) { $so = substr($amount, $length - $i -1 , 1); if ( ($so == 0) && ($i % 3 == 0) && ($unread[$i] == 0)){ for ($j = $i+1 ; $j < $length ; $j ++) { $so1 = substr($amount,$length - $j -1, 1); if ($so1 != 0) break; } if (intval(($j - $i )/3) > 0){ for ($k = $i ; $k <intval(($j-$i)/3)*3 + $i; $k++) $unread[$k] =1; } } } for ($i = 0; $i < $length; $i++) { $so = substr($amount,$length - $i -1, 1); if ($unread[$i] ==1) continue; if ( ($i% 3 == 0) && ($i > 0)) $textnumber = $TextLuythua[$i/3] ." ". $textnumber; if ($i % 3 == 2 ) $textnumber = 'trăm ' . $textnumber; if ($i % 3 == 1) $textnumber = 'mươi ' . $textnumber; $textnumber = $Text[$so] ." ". $textnumber; } //Phai de cac ham replace theo dung thu tu nhu the nay $textnumber = str_replace("không mươi", "lẻ", $textnumber); $textnumber = str_replace("lẻ không", "", $textnumber); $textnumber = str_replace("mươi không", "mươi", $textnumber); $textnumber = str_replace("một mươi", "mười", $textnumber); $textnumber = str_replace("mươi năm", "mươi lăm", $textnumber); $textnumber = str_replace("mươi một", "mươi mốt", $textnumber); $textnumber = str_replace("mười năm", "mười lăm", $textnumber); return ucfirst($textnumber); } }//end class ?>