Hi, Khách!
![]() | ![]() ![]() ![]() ![]() |
Thực sự thì mod này nó nằm sẵn trong code mình share rồi, đàng nào các thánh chả rút ruột được nên share luôn ;

$contents = $msg;
$title = $th;
/*--------------------------------------------------------------------*/
$url = '/forum/';// duđường dẫn tuyệt đối đến thư mục photo
$dir = 'photo';//thu mục mặc định chứa ảnh , không nên sửa
$w=200;//chiều rộng cần resize
$h=200;//chiều cao cần resize
$rs = "yes"; //nếu muốn resise thì để là yes, k thì no
function convert ($str){
$str = html_entity_decode (trim($str),ENT_QUOTES,'UTF-8');
$unicode = array(
'a'=>'á|à|ả|ã|ạ|ă|ắ|ặ|ằ|ẳ|ẵ|â|ấ|ầ|ẩ|ẫ|ậ',
'd'=>'đ',
'e'=>'é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ',
'i'=>'í|ì|ỉ|ĩ|ị',
'o'=>'ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ',
'u'=>'ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự',
'y'=>'ý|ỳ|ỷ|ỹ|ỵ',
'A'=>'Á|À|Ả|Ã|Ạ|Ă|Ắ|Ặ|Ằ|Ẳ|Ẵ|Â|Ấ|Ầ|Ẩ|Ẫ|Ậ',
'D'=>'Đ',
'E'=>'É|È|Ẻ|Ẽ|Ẹ|Ê|Ế|Ề|Ể|Ễ|Ệ',
'I'=>'Í|Ì|Ỉ|Ĩ|Ị',
'O'=>'Ó|Ò|Ỏ|Õ|Ọ|Ô|Ố|Ồ|Ổ|Ỗ|Ộ|Ơ|Ớ|Ờ|Ở|Ỡ|Ợ',
'U'=>'Ú|Ù|Ủ|Ũ|Ụ|Ư|Ứ|Ừ|Ử|Ữ|Ự',
'Y'=>'Ý|Ỳ|Ỷ|Ỹ|Ỵ',
' '=>'-',
'-'=>'\s+',
'' => '[^A-z0-9\-'
);
foreach($unicode as $nonUnicode=>$uni){
$str = preg_replace("/($uni)/i", $nonUnicode, $str);
}
return strtolower ($str);
}
function watermark($input,$source,$link,$w,$h,$rs){
preg_match ('#\.jpg$#i',$input) ? $im_input = imagecreatefromjpeg($input):'';
preg_match ('#\.png$#i',$input) ? $im_input = imagecreatefrompng($input):'';
preg_match ('#\.gif$#i',$input) ? $im_input = imagecreatefromgif($input):'';
$im_source = imagecreatefrompng($source);
imagecopy($im_input, $im_source, imagesx($im_input)-imagesx($im_source)-4, imagesy($im_input)-imagesy($im_source)-4, 0, 0,imagesx($im_source),imagesy($im_source));
if ($rs == 'yes') {
$thumb = imagecreatetruecolor($w, $h);
imagecopyresized($thumb, $im_input, 0, 0, 0, 0, $w, $h, imagesx($im_input), imagesy($im_input));
preg_match ('#\.jpg$#i',$input) ? imagejpeg($thumb,$link):'';
preg_match ('#\.png$#i',$input) ? imagepng($thumb,$link):'';
preg_match ('#\.gif$#i',$input) ? imagegif($thumb,$link):'';
} else {
preg_match ('#\.jpg$#i',$input) ? imagejpeg($im_input,$link):'';
preg_match ('#\.png$#i',$input) ? imagepng($im_input,$link):'';
preg_match ('#\.gif$#i',$input) ? imagegif($im_input,$link):'';
}
}
function get_link ($input) {
preg_match_all ('#\[img\(.+?)\[/img\#i',$input,$regex);
return $regex[1;
}
function get_img ($link,$name) {
copy ($link,$name);
return $name;
}
function replace_link ($a_r,$b_r,$str) {
return str_replace ($a_r,$b_r,$str);
}
$list = get_link ($contents); // l?y danh sách link ?nh
$new = array ();
$d = date ('d',time());
$m = date ('m',time());
$y = date ('y',time());
@mkdir ("$dir/$y/$m/$d",0777,true);
foreach ($list as $key=>$link) {
$end = preg_match('#(\.jpg)$#i',$link) ? '.jpg' : (preg_match('#(\.gif)$#i',$link) ? '.gif':'.png');
//echo "$dir/$y/$m/$d/" . convert ($title) . "-$key-" . $end ;
// print_r ($link) . '<br />';
$new[ = get_img ($link,"$dir/$y/$m/$d/" . convert ($title) . "-$key-" . $end);
watermark ($new[$key,'wtm.png',$new[$key,$w,$h,$rs);
}
foreach ($new as $key=>$val) {
$new[$key = $url . $val;
}
$contents = preg_replace ('#\[img\(.+?)\[/img\#is','[img$1[/img',replace_link ($list,$new,$contents));
/*-------------------------------------------------------------------*/
$msg = $contents;
Copy code
$title = $th;
/*--------------------------------------------------------------------*/
$url = '/forum/';// duđường dẫn tuyệt đối đến thư mục photo
$dir = 'photo';//thu mục mặc định chứa ảnh , không nên sửa
$w=200;//chiều rộng cần resize
$h=200;//chiều cao cần resize
$rs = "yes"; //nếu muốn resise thì để là yes, k thì no
function convert ($str){
$str = html_entity_decode (trim($str),ENT_QUOTES,'UTF-8');
$unicode = array(
'a'=>'á|à|ả|ã|ạ|ă|ắ|ặ|ằ|ẳ|ẵ|â|ấ|ầ|ẩ|ẫ|ậ',
'd'=>'đ',
'e'=>'é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ',
'i'=>'í|ì|ỉ|ĩ|ị',
'o'=>'ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ',
'u'=>'ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự',
'y'=>'ý|ỳ|ỷ|ỹ|ỵ',
'A'=>'Á|À|Ả|Ã|Ạ|Ă|Ắ|Ặ|Ằ|Ẳ|Ẵ|Â|Ấ|Ầ|Ẩ|Ẫ|Ậ',
'D'=>'Đ',
'E'=>'É|È|Ẻ|Ẽ|Ẹ|Ê|Ế|Ề|Ể|Ễ|Ệ',
'I'=>'Í|Ì|Ỉ|Ĩ|Ị',
'O'=>'Ó|Ò|Ỏ|Õ|Ọ|Ô|Ố|Ồ|Ổ|Ỗ|Ộ|Ơ|Ớ|Ờ|Ở|Ỡ|Ợ',
'U'=>'Ú|Ù|Ủ|Ũ|Ụ|Ư|Ứ|Ừ|Ử|Ữ|Ự',
'Y'=>'Ý|Ỳ|Ỷ|Ỹ|Ỵ',
' '=>'-',
'-'=>'\s+',
'' => '[^A-z0-9\-'
);
foreach($unicode as $nonUnicode=>$uni){
$str = preg_replace("/($uni)/i", $nonUnicode, $str);
}
return strtolower ($str);
}
function watermark($input,$source,$link,$w,$h,$rs){
preg_match ('#\.jpg$#i',$input) ? $im_input = imagecreatefromjpeg($input):'';
preg_match ('#\.png$#i',$input) ? $im_input = imagecreatefrompng($input):'';
preg_match ('#\.gif$#i',$input) ? $im_input = imagecreatefromgif($input):'';
$im_source = imagecreatefrompng($source);
imagecopy($im_input, $im_source, imagesx($im_input)-imagesx($im_source)-4, imagesy($im_input)-imagesy($im_source)-4, 0, 0,imagesx($im_source),imagesy($im_source));
if ($rs == 'yes') {
$thumb = imagecreatetruecolor($w, $h);
imagecopyresized($thumb, $im_input, 0, 0, 0, 0, $w, $h, imagesx($im_input), imagesy($im_input));
preg_match ('#\.jpg$#i',$input) ? imagejpeg($thumb,$link):'';
preg_match ('#\.png$#i',$input) ? imagepng($thumb,$link):'';
preg_match ('#\.gif$#i',$input) ? imagegif($thumb,$link):'';
} else {
preg_match ('#\.jpg$#i',$input) ? imagejpeg($im_input,$link):'';
preg_match ('#\.png$#i',$input) ? imagepng($im_input,$link):'';
preg_match ('#\.gif$#i',$input) ? imagegif($im_input,$link):'';
}
}
function get_link ($input) {
preg_match_all ('#\[img\(.+?)\[/img\#i',$input,$regex);
return $regex[1;
}
function get_img ($link,$name) {
copy ($link,$name);
return $name;
}
function replace_link ($a_r,$b_r,$str) {
return str_replace ($a_r,$b_r,$str);
}
$list = get_link ($contents); // l?y danh sách link ?nh
$new = array ();
$d = date ('d',time());
$m = date ('m',time());
$y = date ('y',time());
@mkdir ("$dir/$y/$m/$d",0777,true);
foreach ($list as $key=>$link) {
$end = preg_match('#(\.jpg)$#i',$link) ? '.jpg' : (preg_match('#(\.gif)$#i',$link) ? '.gif':'.png');
//echo "$dir/$y/$m/$d/" . convert ($title) . "-$key-" . $end ;
// print_r ($link) . '<br />';
$new[ = get_img ($link,"$dir/$y/$m/$d/" . convert ($title) . "-$key-" . $end);
watermark ($new[$key,'wtm.png',$new[$key,$w,$h,$rs);
}
foreach ($new as $key=>$val) {
$new[$key = $url . $val;
}
$contents = preg_replace ('#\[img\(.+?)\[/img\#is','[img$1[/img',replace_link ($list,$new,$contents));
/*-------------------------------------------------------------------*/
$msg = $contents;
Copy code
dán code trên vào file nt.php trong forum/, sau
if (!$error) {
unset($_SESSION['token');
roi tạo 1 ảnh logo tên wtm.png đem vứt vào trong forum

Trực Tuyến:
Khách: 1