���� 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/thietkewebvumi.com/lib/ |
<?php class FUNC { var $textcount = 0; function timestam2h($time){ global $CORE; $gio = intval($time/3600); $time = $time-$gio*3600; $phut = intval($time/60); $giay = $time-$phut*60; if ($CORE->lang_type!='en'){ return $gio.' giờ '.$phut.' phút '.$giay.' giây'; }else{ return $gio.' hours '.$phut.' minutes '.$giay.' seconds'; } } function randomdigit($digits) { static $startseed = 0; if (!$startseed) { $startseed = (double)microtime()*getrandmax(); srand($startseed); } $range = 8; $start = 1; $i = 1; while ($i<$digits) { $range = $range . 9; $start = $start . 0; $i++; } return (rand()%$range+$start); } function build_link($array) { global $CORE; $url = $CORE->index_url; foreach ( $array as $k => $v ) { $url .= "&".$k."=".$v; } return $url; } function editor_new($name,$data,$row){ global $INFO; $INFO['home_editor'] = (AD_IN==1) ? '../' : ''; $txthtml = '<script type="text/javascript"> tinymce.init({ selector: "textarea#'.$name.'", theme: "modern", width: 680, height: 200, plugins: [ "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker", "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking", "save table contextmenu directionality emoticons template paste textcolor filemanager" ], content_css: "css/content.css", toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | l ink image | print preview media fullpage | forecolor backcolor emoticons", }); </script>'; $txthtml .= '<textarea id="'.$name.'" name="'.$name.'" rows="'.$row.'" style="width:70%"> '.$data.' </textarea>'; return $txthtml; } function editor_admin($name,$data,$row){ global $homeurl,$INFO; $rel_path = (AD_IN==1) ? '../' : ''; $txthtml = ' <script type="text/javascript"> tinyMCE.init({ // General options mode : "exact", elements : "'.$name.'", theme : "advanced", skin : "o2k7", plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups", // Theme options theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect", theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor", theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen", theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_statusbar_location : "bottom", theme_advanced_resizing : true, plugin_insertdate_dateFormat : "%d-%m-%Y", plugin_insertdate_timeFormat : "%H:%M:%S", // Example word content CSS (should be your site CSS) this one removes paragraph margins content_css : "'.$INFO['home_url'].'editor/tiny_mce2/css/word.css", // Drop lists for link/image/media/template dialogs template_external_list_url : "'.$INFO['home_url'].'editor/tiny_mce2/lists/template_list.js", external_link_list_url : "'.$INFO['home_url'].'editor/tiny_mce2/lists/link_list.js", external_image_list_url : "'.$INFO['home_url'].'editor/tiny_mce2/lists/image_list.js", media_external_list_url : "'.$INFO['home_url'].'editor/tiny_mce2/lists/media_list.js", //file editor document_base_url : "/", file_browser_callback : "fileBrowserCallBack", // Replace values for the template plugin template_replace_values : { username : "Some User", staffid : "991234" } }); function fileBrowserCallBack(field_name, url, type, win) { var connector = "'.$homeurl.'editor/tiny_mce2/filemanager/browser.html?Connector=connectors/php/connector.php"; var enableAutoTypeSelection = true; var cType; tinymcpuk_field = field_name; tinymcpuk = win; switch (type) { case "image": cType = "Image"; break; case "flash": cType = "Flash"; break; case "file": cType = "File"; break; } if (enableAutoTypeSelection && cType) { connector += "&Type=" + cType; } window.open(connector, "tinymcpuk", "modal,width=600,height=400"); } </script>'; $txthtml .= '<textarea id="'.$name.'" name="'.$name.'" rows="'.$row.'" style="width:100%"> '.$data.' </textarea>'; return $txthtml; } function editor_jquery($name,$data,$row,$class_name){ global $INFO; $html_editor = '<script type="text/javascript"> $().ready(function() { $(\'textarea.'.$class_name.'\').tinymce({ // Location of TinyMCE script script_url : \''.$INFO['home_url'].'tinymce/tiny_mce.js\', // General options theme : "advanced", skin : "o2k7", plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist,imagemanager", // Theme options theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect", theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor", theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen", theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,|,insertimage", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_statusbar_location : "bottom", theme_advanced_resizing : true, // Replace values for the template plugin template_replace_values : { username : "Some User", staffid : "991234" } }); }); </script>'; $html_editor .= '<textarea name="'.$name.'" rows="'.$row.'" class="'.$class_name.'">'.$data.'</textarea>'; return $html_editor; } 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_template($name) { global $CORE, $INFO; if ($CORE->skin=="") $CORE->skin = $CORE->vars['skin']; if (!is_dir("skin/".$CORE->skin )) { $CORE->skin = $CORE->vars['skin']; } $CORE->img = $INFO['home_url']."/skin/".$CORE->skin."/images/"; require ROOT_PATH."skin/".$CORE->skin."/{$name}.php"; return new $name (); } 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; } /*------------------------------------------------------------------------- */ // Makes incoming info "safe" /*------------------------------------------------------------------------- */ function get_input() { global $_GET, $_POST, $REQUEST_METHOD, $REMOTE_ADDR, $HTTP_PROXY_USER, $HTTP_X_FORWARDED_FOR; $return = array(); if( is_array($_GET) ) { while( list($k, $v) = each($_GET)) { if ( $k == 'INFO' ) { continue; } if( is_array($_GET[$k]) ) { while( list($k2, $v2) = each($_GET[$k]) ) { $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) ) { while( list($k, $v) = each($_POST) ) { if ( is_array($_POST[$k]) ) { while( list($k2, $v2) = each($_POST[$k]) ) { $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 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($string){ $string = trim($string); $string = $this->bodau($string); $string = $this->clean_key($string); $string = str_replace(' ','-',$string); $string = strtolower($string); $string = preg_replace('/[^a-z0-9]+/i', '-', $string); $string = preg_replace('/\-+/', '-', $string); $string = trim($string, '-'); return empty($string) ? "olaalo_list" : $string; //return $string; } function clean_value($val) { global $CORE; 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 create_image($file, $type, $name , $size, $path) { switch($type) { //png case 'image/png': $this->create_png($file, $type, $name , $size, $path); $value = 3; break; case 'image/x-png': $this->create_png($file, $type, $name , $size, $path); $value = 3; break; case 'image/jpeg': $this->create_jpeg($file, $type, $name , $size, $path); $value = 1; break; case 'image/gif': $this->create_gif($file, $type, $name, $size, $path); $value = 2; break; case 'image/pjpeg': $this->create_jpeg($file, $type, $name, $size, $path); $value = 1; break; default: $value = 0; } return $value; } //png function create_png($file,$type, $name, $size, $path) { $rsize = $this->resize_image($file, $size); $rwidth = $rsize['width']; $rheight = $rsize['height']; $image_tmp = @imagecreatefrompng($file); $img_size = @getimagesize($file); $thumb = @imagecreatetruecolor($rwidth,$rheight); @imagecopyresized($thumb, $image_tmp,0,0,0,0,$rwidth,$rheight,$img_size[0],$img_size[1]); @imagepng($thumb,$path.$name.".png"); //88 = new filesize @imagedestroy( $thumb ); @imagedestroy( $image_tmp ); } function create_jpeg($file,$type, $name, $size, $path) { $rsize = $this->resize_image($file, $size); $rwidth = $rsize['width']; $rheight = $rsize['height']; $image_tmp = imagecreatefromjpeg($file); $img_size = getimagesize($file); $thumb = imagecreatetruecolor($rwidth,$rheight); imagecopyresized($thumb, $image_tmp,0,0,0,0,$rwidth,$rheight,$img_size[0],$img_size[1]); imagejpeg($thumb,$path.$name.".jpg"); //88 = new filesize imagedestroy( $thumb ); imagedestroy( $image_tmp ); } function create_gif($file,$type, $name, $size, $path) { if($size != 0){ $rsize = $this->resize_image($file, $size); }else{ $rsize = getimagesize($file); } $rwidth = $rsize['width']; $rheight = $rsize['height']; $image_tmp = @imagecreatefromgif($file); $img_size = @getimagesize($file); $thumb = @imagecreatetruecolor($rwidth,$rheight); @imagecopyresized($thumb, $image_tmp,0,0,0,0,$rwidth,$rheight,$img_size[0],$img_size[1]); @imagegif( $thumb,$path.$name.".gif"); @imagedestroy( $thumb ); @imagedestroy( $image_tmp ); } function resize_image($string,$sizer) { $image = getimagesize($string); if($image['0'] > $image['1']) { $tmp_size = $image['0']/$sizer; } else { $tmp_size = $image['1']/$sizer; } $width = $image['0']/$tmp_size; $height = $image['1']/$tmp_size; $size['width'] = $width; $size['height'] = $height; return $size; } function getImageExt($imageType) { $stringExt = ""; if($imageType == 1) { $stringExt = ".jpg"; } elseif($imageType == 2) { $stringExt = ".gif"; }elseif($imageType == 3) { $stringExt = ".png"; } return $stringExt; } function get_file_extension($file_name) { return substr(strrchr($file_name,'.'),1); } function my_setcookie($name, $value = "", $sticky = 1) { global $CORE; if ($sticky == 1) { $expires = time() + 60*60*24*365; } $CORE->vars['cookie_domain'] = $CORE->vars['cookie_domain'] == "" ? "" : $CORE->vars['cookie_domain']; $CORE->vars['cookie_path'] = $CORE->vars['cookie_path'] == "" ? "/" : $CORE->vars['cookie_path']; $name = $CORE->vars['cookie_id'].$name; @setcookie($name, $value, $expires, $CORE->vars['cookie_path'], $CORE->vars['cookie_domain']); } function show_gd_img($content="") { global $CORE, $DB; $content = ' '. preg_replace( "/(\w)/", "\\1 ", $content ) .' '; @header("Content-Type: image/jpeg"); $tmp_x = 140; $tmp_y = 20; $image_x = 210; $image_y = 65; $circles = 3; $tmp = imagecreatetruecolor($tmp_x, $tmp_y); $im = imagecreatetruecolor($image_x, $image_y); $white = ImageColorAllocate($tmp, 255, 255, 255); $black = ImageColorAllocate($tmp, 0, 0, 0); $grey = ImageColorAllocate($tmp, 210, 210, 210 ); imagefill($tmp, 0, 0, $white); for ( $i = 1; $i <= $circles; $i++ ) { $values = array( 0 => rand(0, $tmp_x - 10), 1 => rand(0, $tmp_y - 3), 2 => rand(0, $tmp_x - 10), 3 => rand(0, $tmp_y - 3), 4 => rand(0, $tmp_x - 10), 5 => rand(0, $tmp_y - 3), 6 => rand(0, $tmp_x - 10), 7 => rand(0, $tmp_y - 3), 8 => rand(0, $tmp_x - 10), 9 => rand(0, $tmp_y - 3), 10 => rand(0, $tmp_x - 10), 11 => rand(0, $tmp_y - 3), ); $randomcolor = imagecolorallocate( $tmp, rand(100,255), rand(100,255),rand(100,255) ); imagefilledpolygon($tmp, $values, 6, $randomcolor ); } imagestring($tmp, 5, 0, 2, $content, $black); //----------------------------------------- // Distort by resizing //----------------------------------------- imagecopyresized($im, $tmp, 0, 0, 0, 0, $image_x, $image_y, $tmp_x, $tmp_y); imagedestroy($tmp); $white = ImageColorAllocate($im, 255, 255, 255); $black = ImageColorAllocate($im, 0, 0, 0); $grey = ImageColorAllocate($im, 100, 100, 100 ); $random_pixels = $image_x * $image_y / 10; for ($i = 0; $i < $random_pixels; $i++) { ImageSetPixel($im, rand(0, $image_x), rand(0, $image_y), $black); } $no_x_lines = ($image_x - 1) / 5; for ( $i = 0; $i <= $no_x_lines; $i++ ) { // X lines ImageLine( $im, $i * $no_x_lines, 0, $i * $no_x_lines, $image_y, $grey ); // Diag lines ImageLine( $im, $i * $no_x_lines, 0, ($i * $no_x_lines)+$no_x_lines, $image_y, $grey ); } $no_y_lines = ($image_y - 1) / 5; for ( $i = 0; $i <= $no_y_lines; $i++ ) { ImageLine( $im, 0, $i * $no_y_lines, $image_x, $i * $no_y_lines, $grey ); } ImageJPEG($im); ImageDestroy($im); exit(); } /*-------------------------------------------------------------------------*/ // // Show NORMAL created security image(s)... // /*-------------------------------------------------------------------------*/ function show_gif_img($this_number="") { global $CORE, $DB; $numbers = array( 0 => 'R0lGODlhCAANAJEAAAAAAP////4BAgAAACH5BAQUAP8ALAAAAAAIAA0AAAIUDH5hiKsOnmqSPjtT1ZdnnjCUqBQAOw==', 1 => 'R0lGODlhCAANAJEAAAAAAP////4BAgAAACH5BAQUAP8ALAAAAAAIAA0AAAIUjAEWyMqoXIprRkjxtZJWrz3iCBQAOw==', 2 => 'R0lGODlhCAANAJEAAAAAAP////4BAgAAACH5BAQUAP8ALAAAAAAIAA0AAAIUDH5hiKubnpPzRQvoVbvyrDHiWAAAOw==', 3 => 'R0lGODlhCAANAJEAAAAAAP////4BAgAAACH5BAQUAP8ALAAAAAAIAA0AAAIVDH5hiKbaHgRyUZtmlPtlfnnMiGUFADs=', 4 => 'R0lGODlhCAANAJEAAAAAAP////4BAgAAACH5BAQUAP8ALAAAAAAIAA0AAAIVjAN5mLDtjFJMRjpj1Rv6v1SHN0IFADs=', 5 => 'R0lGODlhCAANAJEAAAAAAP////4BAgAAACH5BAQUAP8ALAAAAAAIAA0AAAIUhA+Bpxn/DITL1SRjnps63l1M9RQAOw==', 6 => 'R0lGODlhCAANAJEAAAAAAP////4BAgAAACH5BAQUAP8ALAAAAAAIAA0AAAIVjIEYyWwH3lNyrQTbnVh2Tl3N5wQFADs=', 7 => 'R0lGODlhCAANAJEAAAAAAP////4BAgAAACH5BAQUAP8ALAAAAAAIAA0AAAIUhI9pwbztAAwP1napnFnzbYEYWAAAOw==', 8 => 'R0lGODlhCAANAJEAAAAAAP////4BAgAAACH5BAQUAP8ALAAAAAAIAA0AAAIVDH5hiKubHgSPWXoxVUxC33FZZCkFADs=', 9 => 'R0lGODlhCAANAJEAAAAAAP////4BAgAAACH5BAQUAP8ALAAAAAAIAA0AAAIVDA6hyJabnnISnsnybXdS73hcZlUFADs=', ); @header("Content-Type: image/gif"); echo base64_decode($numbers[ $this_number ]); exit(); } function make_password() { $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 < 6; $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 prevent_multi_submit($type = "post", $excl = "validator") { $string = ""; foreach ($_POST as $key => $val) { // this test is new in version 1.01 to exclude a single variable if ($key != $excl) { $string .= $val; } } if (isset($_SESSION['last'])) { if ($_SESSION['last'] === md5($string)) { return false; } else { $_SESSION['last'] = md5($string); return true; } } else { $_SESSION['last'] = md5($string); return true; } } function commify($str) { $n = strlen($str); if($n <= 3){ $return = $str; }else{ $pre = substr($str,0,$n-3); $post = substr($str,$n-3,3); $pre = $this->commify($pre); $return = str_replace(",.",".","$pre.$post"); } return($return); } function commifyvnd($str){ $str_arr = explode('.',$str); if($str_arr[1]>0){ $show_commify = $str_arr[0].' triệu '.$str_arr[1].'0'.' nghìn'; }else{ $show_commify = $str_arr[0].' triệu '; } return $show_commify; } 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 random_character($count) { $random_char = ""; $char_base = explode( " ", "a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9"); for( $i = 1; $i < $count; $i++ ) { $random_char = $random_char.$char_base[rand(9, count($char_base))]; } return $random_char; } function get_sub_content($content,$strBegin,$strEnd) { //$content = file_get_contents('http://www.nchmf.gov.vn/website/vi-VN/43/Default.aspx'); //$strBegin = '<!-- Begin Display content -->'; //$strEnd = '<TD class="thoitiet_rightbox_ver"></TD>'; $pos1 = strpos($content, $strBegin); if(false === $pos1) { return ''; } else { $pos2 = strpos($content, $strEnd); $content = substr($content, $pos1, ($pos2-$pos1)); return strip_tags($content, '<table><tr><td><img><a><object><param><embed>');//cho hep tag nào hiển thị trong code html } } function list_check_bok($input_name){ //$input_name as a array $list_selected_id = implode(',', $input_name); return $list_selected_id; } 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 timestamp($date_db){ //$date_db co dang '2009-03-25'; $arr_date = explode('-',$date_db); $time_stamp=gmmktime(0,0,0,$arr_date[1],$arr_date[2],$arr_date[0]); return $time_stamp; } function current_url() { $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == 'on') ? 's' : ''; // $protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), '/').$s; $port = ($_SERVER["SERVER_PORT"] == '80') ? '' : (':'.$_SERVER["SERVER_PORT"]); return 'http'.$s.'://'.$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI']; } function downloadImage($url,$dir_name){ //global $mainsid; $seid = md5(uniqid(microtime())); $filename = $seid.'.jpg'; //$thumb = 'thumb_'.$seid.'.jpg'; $filenum=@fopen($url,"rb"); $fileout=@fopen(ROOT_PATH."upload/$dir_name/$filename","wb"); if ($filenum!=0){ while (!@feof($filenum)){ @fwrite($fileout,@fread($filenum,1024)); } } @fclose($filenum); @fclose($fileout); return $filename; } 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 getPage ($url) { if (function_exists('curl_init')) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); return curl_exec($ch); } else { return file_get_contents($url); } } /* MyToUpper($strToUpper) Chuyen doi chuoi thanh chu hoa co cac ky tu tieng viet */ function MyToUpper($sSrc) { $arrVietNamese = array( 'a'=>'A', 'à'=>'À', 'á'=>'Á', 'ả'=>'Ả', 'ã'=>'Ã', 'ạ'=>'Ạ', 'ă'=>'Ă', 'ằ'=>'Ằ', 'ắ'=>'Ắ', 'ẳ'=>'Ẳ', 'ẵ'=>'Ẵ', 'ặ'=>'Ặ', 'â'=>'Â', 'ầ'=>'Ầ', 'ấ'=>'Ấ', 'ẩ'=>'Ẩ', 'ẫ'=>'Ẫ', 'ậ'=>'Ậ', 'o'=>'O', 'ò'=>'Ò', 'ó'=>'Ó', 'ỏ'=>'Ỏ', 'õ'=>'Õ', 'ọ'=>'Ọ', 'ô'=>'Ô', 'ồ'=>'Ồ', 'ố'=>'Ố', 'ổ'=>'Ổ', 'ỗ'=>'Ỗ', 'ộ'=>'Ộ', 'ơ'=>'Ơ', 'ờ'=>'Ờ', 'Ớ'=>'Ớ', 'ở'=>'Ở', 'ỡ'=>'Ỡ', 'ợ'=>'Ợ', 'e'=>'E', 'è'=>'È', 'é'=>'É', 'ẻ'=>'Ẻ', 'ẽ'=>'Ẽ', 'ẹ'=>'Ẹ', 'ê'=>'Ê', 'ề'=>'Ề', 'ế'=>'Ế', 'ể'=>'Ể', 'ễ'=>'Ễ', 'ệ'=>'Ệ', 'u'=>'U', 'ù'=>'Ù', 'ú'=>'Ú', 'ủ'=>'Ủ', 'ũ'=>'Ũ', 'ụ'=>'Ụ', 'ư'=>'Ư', 'ừ'=>'Ừ', 'ứ'=>'Ứ', 'ử'=>'Ử', 'ữ'=>'Ữ', 'ự'=>'Ự', 'i'=>'I', 'ì'=>'Ì', 'í'=>'Í', 'ỉ'=>'Ỉ', 'ĩ'=>'Ĩ', 'ị'=>'Ị', 'y'=>'Y', 'ỳ'=>'Ỳ', 'ý'=>'Ý', 'ỷ'=>'Ỷ', 'ỹ'=>'Ỹ', 'ỵ'=>'Ỵ', 'đ'=>'Đ'); for($i = 'a'; $i < 'z'; $i++) { $arrVietNamese[$i] = strtoupper($i); } $arrVietNamese['z'] = 'Z'; foreach($arrVietNamese as $key=>$value) { $sSrc = str_replace($key, $value, $sSrc); } return($sSrc); } /* MyToLower($strToUpper) Chuyen doi chuoi thanh chu hoa co cac ky tu tieng viet */ function MyToLower($sSrc) { $arrVietNamese = array( 'a'=>'A', 'à'=>'À', 'á'=>'Á', 'ả'=>'Ả', 'ã'=>'Ã', 'ạ'=>'Ạ', 'ă'=>'Ă', 'ằ'=>'Ằ', 'ắ'=>'Ắ', 'ẳ'=>'Ẳ', 'ẵ'=>'Ẵ', 'ặ'=>'Ặ', 'â'=>'Â', 'ầ'=>'Ầ', 'ấ'=>'Ấ', 'ẩ'=>'Ẩ', 'ẫ'=>'Ẫ', 'ậ'=>'Ậ', 'o'=>'O', 'ò'=>'Ò', 'ó'=>'Ó', 'ỏ'=>'Ỏ', 'õ'=>'Õ', 'ọ'=>'Ọ', 'ô'=>'Ô', 'ồ'=>'Ồ', 'ố'=>'Ố', 'ổ'=>'Ổ', 'ỗ'=>'Ỗ', 'ộ'=>'Ộ', 'ơ'=>'O', 'ờ'=>'Ờ', 'Ớ'=>'Ớ', 'ở'=>'Ở', 'ỡ'=>'Ỡ', 'ợ'=>'Ợ', 'e'=>'E', 'è'=>'È', 'é'=>'É', 'ẻ'=>'Ẻ', 'ẽ'=>'Ẽ', 'ẹ'=>'Ẹ', 'ê'=>'Ê', 'ề'=>'Ề', 'ế'=>'Ế', 'ể'=>'Ể', 'ễ'=>'Ễ', 'ệ'=>'Ệ', 'u'=>'U', 'ù'=>'Ù', 'ú'=>'Ú', 'ủ'=>'Ủ', 'ũ'=>'Ũ', 'ụ'=>'Ụ', 'ư'=>'Ư', 'ừ'=>'Ừ', 'ứ'=>'Ứ', 'ử'=>'Ử', 'ữ'=>'Ữ', 'ự'=>'Ự', 'i'=>'I', 'ì'=>'Ì', 'í'=>'Í', 'ỉ'=>'Ỉ', 'ĩ'=>'Ĩ', 'ị'=>'Ị', 'y'=>'Y', 'ỳ'=>'Ỳ', 'ý'=>'Ý', 'ỷ'=>'Ỷ', 'ỹ'=>'Ỹ', 'ỵ'=>'Ỵ', 'đ'=>'Đ'); for($i = 'a'; $i < 'z'; $i++) { $arrVietNamese[$i] = strtoupper($i); } $arrVietNamese['z'] = 'Z'; foreach($arrVietNamese as $key=>$value) { $sSrc = str_replace($value, $key, $sSrc); } return($sSrc); } //list dir function listdirs($dir) { $dirs = glob($dir . '/*', GLOB_ONLYDIR); foreach ($dirs as $dir) { $alldirs[] = $dir; } return $alldirs; } function img_size($path_img,$max_width,$max_height){ $arr_size = getimagesize($path_img); $width = $arr_size[0]; $height = $arr_size[1]; $ratioh = $max_height/$height; $ratiow = $max_width/$width; $ratio = min($ratioh, $ratiow); // New dimensions $arr['width'] = intval($ratio*$width); $arr['height'] = intval($ratio*$height); return $arr; } function path_image_sub($path_image){ global $INFO; $folderName = date('m_y'); $pathToUpload = $_SERVER['DOCUMENT_ROOT'].$INFO['path_host'].'/'.$path_image.$folderName; if(!is_dir($pathToUpload)){ $old = umask(0); $create = mkdir($pathToUpload, 0777); umask($old); if(!$create){ echo 'Khong the tao folder'; exit(); } } return $pathToUpload.'/'; } function not_empty_folder($path_image){ $directory = dir($path_image); // Loop while the read method goes through each and // every file $directory_not_empty = 0; while(false !== ($item = $directory->read())){ // If an item is not "." and "..", then something // exists in the directory and it is not empty if ($item != '.' && $item != '..'){ $directory_not_empty = 1; } } // Close the directory $directory->close(); return $directory_not_empty; } function getStringConvert($str) { $foreign_characters = array( '/ä|æ|ǽ/' => 'ae', '/ö|œ/' => 'oe', '/ü/' => 'ue', '/Ä/' => 'Ae', '/Ü/' => 'Ue', '/Ö/' => 'Oe', '/À|Á|Â|Ã|Ä|Å|Ǻ|Ā|Ă|Ą|Ǎ|Ạ|Ấ|Ầ|Ẫ|Ẩ|Ậ|Ắ|Ẳ|Ẵ|Ặ|Ả|Ã|A/' => 'A', '/à|á|â|ã|å|ǻ|ā|ă|ą|ǎ|ª|ạ|ấ|ầ|ẫ|ẩ|ậ|ắ|ẳ|ẵ|ặ|ả|ã/' => 'a', '/Ç|Ć|Ĉ|Ċ|Č/' => 'C', '/ç|ć|ĉ|ċ|č/' => 'c', '/Ð|Ď|Đ/' => 'D', '/ð|ď|đ/' => 'd', '/È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě|Ể|Ễ|Ệ|Ề|Ế|Ẽ|Ẻ|Ẹ/' => 'E', '/è|é|ê|ë|ē|ĕ|ė|ę|ě|ể|ễ|ệ|ề|ế|ẽ|ẻ|ẹ/' => 'e', '/Ĝ|Ğ|Ġ|Ģ/' => 'G', '/ĝ|ğ|ġ|ģ/' => 'g', '/Ĥ|Ħ/' => 'H', '/ĥ|ħ/' => 'h', '/Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ|Ị|Ỉ/' => 'I', '/ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı|ị|ỉ/' => 'i', '/Ĵ/' => 'J', '/ĵ/' => 'j', '/Ķ/' => 'K', '/ķ/' => 'k', '/Ĺ|Ļ|Ľ|Ŀ|Ł/' => 'L', '/ĺ|ļ|ľ|ŀ|ł/' => 'l', '/Ñ|Ń|Ņ|Ň/' => 'N', '/ñ|ń|ņ|ň|ʼn/' => 'n', '/Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ|Õ|Ỏ|Ọ|Ố|Ồ|Ổ|Ỗ|Ộ|Ở|Ỡ|Ợ|Õ|Ỏ|Ờ|Ớ|Ở|Ỡ/' => 'O', '/ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º|ỏ|ọ|ố|ồ|ổ|ỗ|ộ|ở|ỡ|ợ|õ|ỏ|ờ|ở|ỡ|ớ/' => 'o', '/Ŕ|Ŗ|Ř/' => 'R', '/ŕ|ŗ|ř/' => 'r', '/Ś|Ŝ|Ş|Š/' => 'S', '/ś|ŝ|ş|š|ſ/' => 's', '/Ţ|Ť|Ŧ/' => 'T', '/ţ|ť|ŧ/' => 't', '/Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ|Ủ|Ụ|Ũ|Ữ|Ử|Ự|Ừ|Ứ|Ử|Ữ/' => 'U', '/ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ|ủ|ụ|ũ|ữ|ử|ự|ừ|ứ/' => 'u', '/Ý|Ÿ|Ŷ|Ỳ|Ý|Ỹ|Ỷ|Ỵ/' => 'Y', '/ý|ÿ|ŷ|ỳ|ỹ|ỷ|ỵ/' => 'y', '/Ŵ/' => 'W', '/ŵ/' => 'w', '/Ź|Ż|Ž/' => 'Z', '/ź|ż|ž/' => 'z', '/Æ|Ǽ/' => 'AE', '/ß/'=> 'ss', '/IJ/' => 'IJ', '/ij/' => 'ij', '/Œ/' => 'OE', '/ƒ/' => 'f' ); return preg_replace(array_keys($foreign_characters), array_values($foreign_characters), $str); } function getUrlTitle($str, $separator = '-', $lowercase = FALSE){ if ($separator == 'dash') { $separator = '-'; } else if ($separator == 'underscore') { $separator = '_'; } $q_separator = preg_quote($separator); $trans = array( '&.+?;' => '', '[^a-z0-9 _-]' => '', '\s+' => $separator, '('.$q_separator.')+' => $separator ); $str = strip_tags($str); foreach ($trans as $key => $val) { $str = preg_replace("#".$key."#i", $val, $str); } if ($lowercase === TRUE) { $str = strtolower($str); } return trim($str, $separator); } }//end class ?>