���� 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/okanime.top/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 = ''; if(!empty($_SERVER["HTTPS"]) and $_SERVER["HTTPS"] == 'on' ){ $s = '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; } } // 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($number) { $hyphen = ' '; $conjunction = ' '; $separator = ' '; $negative = 'âm '; $decimal = ' phẩy '; $dictionary = array( 0 => 'Không', 1 => 'Một', 2 => 'Hai', 3 => 'Ba', 4 => 'Bốn', 5 => 'Năm', 6 => 'Sáu', 7 => 'Bảy', 8 => 'Tám', 9 => 'Chín', 10 => 'Mười', 11 => 'Mười một', 12 => 'Mười hai', 13 => 'Mười ba', 14 => 'Mười bốn', 15 => 'Mười năm', 16 => 'Mười sáu', 17 => 'Mười bảy', 18 => 'Mười tám', 19 => 'Mười chín', 20 => 'Hai mươi', 30 => 'Ba mươi', 40 => 'Bốn mươi', 50 => 'Năm mươi', 60 => 'Sáu mươi', 70 => 'Bảy mươi', 80 => 'Tám mươi', 90 => 'Chín mươi', 100 => 'trăm', 1000 => 'ngàn', 1000000 => 'triệu', 1000000000 => 'tỷ', 1000000000000 => 'nghìn tỷ', 1000000000000000 => 'ngàn triệu triệu', 1000000000000000000 => 'tỷ tỷ' ); if( !is_numeric( $number ) ) { return false; } if( ($number >= 0 && (int)$number < 0) || (int)$number < 0 - PHP_INT_MAX ) { // overflow trigger_error( 'convert_number_to_words only accepts numbers between -' . PHP_INT_MAX . ' and ' . PHP_INT_MAX, E_USER_WARNING ); return false; } if( $number < 0 ) { return $negative . $this->convert_number_to_words( abs( $number ) ); } $string = $fraction = null; if( strpos( $number, '.' ) !== false ) { list( $number, $fraction ) = explode( '.', $number ); } switch (true) { case $number < 21: $string = $dictionary[$number]; break; case $number < 100: $tens = ((int)($number / 10)) * 10; $units = $number % 10; $string = $dictionary[$tens]; if( $units ) { $string .= $hyphen . $dictionary[$units]; } break; case $number < 1000: $hundreds = $number / 100; $remainder = $number % 100; $string = $dictionary[$hundreds] . ' ' . $dictionary[100]; if( $remainder ) { $string .= $conjunction . $this->convert_number_to_words( $remainder ); } break; default: $baseUnit = pow( 1000, floor( log( $number, 1000 ) ) ); $numBaseUnits = (int)($number / $baseUnit); $remainder = $number % $baseUnit; $string = $this->convert_number_to_words( $numBaseUnits ) . ' ' . $dictionary[$baseUnit]; if( $remainder ) { $string .= $remainder < 100 ? $conjunction : $separator; $string .= $this->convert_number_to_words( $remainder ); } break; } if( null !== $fraction && is_numeric( $fraction ) ) { $string .= $decimal; $words = array( ); foreach( str_split((string) $fraction) as $number ) { $words[] = $dictionary[$number]; } $string .= implode( ' ', $words ); } return $string; } function Detect_Mobile_Browser(){ $useragent=$_SERVER['HTTP_USER_AGENT']; if(preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i',substr($useragent,0,4))){ return 'mobile'; } return 'pc'; } function time_site($date){ $time = strtotime($date); if(time()-$time<=24*60*60){ return '<span class="text-danger">New</span>'; } return date('F j, Y',$time); } function time_ago($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 "just now"; } //Minutes else if($minutes <=60){ if($minutes==1){ return "one minute ago"; } else{ return "$minutes minutes ago"; } } //Hours else if($hours <=24){ if($hours==1){ return "an hour ago"; }else{ return "$hours hrs ago"; } } //Days else if($days <= 7){ if($days==1){ return "yesterday"; }else{ return "$days days ago"; } } //Weeks else if($weeks <= 4.3){ if($weeks==1){ return "a week ago"; }else{ return "$weeks weeks ago"; } } //Months else if($months <=12){ if($months==1){ return "a month ago"; }else{ return "$months months ago"; } } //Years else{ if($years==1){ return "one year ago"; }else{ return date('F j, Y',$time_ago); } } } function makeid(){ return md5($_SERVER['HTTP_USER_AGENT'].$_SERVER['HTTP_ACCEPT_LANGUAGE'].$_SERVER['REMOTE_ADDR']); } }//end class ?>