BLOGCODE.HEXAT.COM

- TIEUTHUYET.TOP - Đọc truyện trên điện thoại
- NoiDau.Net - Đọc Truyện Online
- Phòng Chat Thảo Luận WapMaster
HomeMod JohncmsShare
Tìm kiếm
▲ Mod like để tải file đính kèm cho JohnCMS
** Admin admin
27-03-2018
Link google đã die hết nên mình share lại
Đầu tiên các bạn chạy sql
ALTER TABLE `cms_forum_files` ADD `reqthank` int(2) NOT NULL default 0;
Mở forum/includes/addfiles.php tìm

$res3 = mysql_fetch_array($req3);
// Заносим данные в базу
mysql_query("INSERT INTO `cms_forum_files` SET
`cat` = '" . $res3['refid'] . "',
`subcat` = '" . $res2['refid'] . "',
`topic` = '" . $res['refid'] . "',
`post` = '$id',
`time` = '" . $res['time'] . "',
`filename` = '" . mysql_real_escape_string($fname) . "',
`filetype` = '$type'
");

Thay thành

$chkthank = isset($_REQUEST['chkthank']);
$chkthank = ($chkthank ? '1' : '0');
// Заносим данные в базу
mysql_query("INSERT INTO `cms_forum_files` SET
`cat` = '" . $res3['refid'] . "',
`subcat` = '" . $res2['refid'] . "',
`topic` = '" . $res['refid'] . "',
`post` = '$id',
`time` = '" . $res['time'] . "',
`filename` = '" . mysql_real_escape_string($fname) . "',
`filetype` = '$type',
`reqthank` = '$chkthank'
");

Tìm

echo '</p><p><input type="submit" name="submit" value="' . $lng_forum['upload'] . '"/></p></form></div>' .

Thêm vào bên trên

echo '<div class="list1">Yêu cầu Thank bài viết<input type="checkbox" name="chkthank" value="1" /></div>';

Mở forum/includes/file.php tìm

if (file_exists('../files/forum/attach/' . $res['filename'])) {

Thêm vào bên dưới

if ($fres['reqthank'] == '1') {
$resid = mysql_query("SELECT * FROM `forum` WHERE `id` = '$id'");
$checkthank = mysql_query('SELECT COUNT(*) FROM `forum_thank` WHERE `userthank` = "' . $user_id . '" and `topic` = "' . $id . '" and `user` = "' . $resid['user_id'] . '"');
$thankcheck = mysql_result($checkthank, 0);
if($thankcheck < 1 && $user_id != $resid['user_id']) {
require('../incfiles/head.php');
echo functions::display_error('Bạn chưa cảm ơn bài viết', '<a href="index.php">' . $lng['to_forum'] . '</a>');
require('../incfiles/end.php');
exit;
}
}

Tìm tiếp

header('location: ../files/forum/attach/' . $res['filename']);

Thay thế thành

$path = '../files/forum/attach/' . $res['filename'];
$infofile = pathinfo($path);
$file_ext = strtolower($infofile['extension']);
if($file_ext == 'bmp') {
$ftype = 'image/bmp';
}
if($file_ext == 'png') {
$ftype = 'image/png';
}
if($file_ext == 'gif') {
$ftype = 'image/gif';
}
if($file_ext == 'jpg' || $file_ext == 'jpeg') {
$ftype = 'image/jpeg';
}
if($file_ext == 'jar') {
$ftype = 'application/java-archive';
}
if($file_ext == 'zip') {
$ftype = 'application/zip';
}
if($file_ext == 'txt') {
$ftype = 'text/plain';
}
if($file_ext == 'rar') {
$ftype = 'application/x-rar-compressed';
}
if($file_ext == 'mp4') {
$ftype = 'video/mp4';
}
if($file_ext == '3gp') {
$ftype = 'video/3gpp';
}
if($file_ext == 'exe') {
$ftype = 'application/octet-stream';
}
header('Cache-Control: public');
header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename=JohnMCSVN-'.$res['filename']);
header('Content-type: '.$ftype);
header('Content-Transfer-Encoding: binary');
readfile($path);
exit;
?>


Mở forum/index.php

Tìm
PHP Code:
<?php
echo '<br /><a href="index.php?act=file&id=' . $fres['id'] . '">' . $fres['filename'] . '</a>';
?>


Thay thành

PHP Code:
<?php
if ($fres['reqthank'] == '1') {
$checkthank = mysql_query('SELECT COUNT(*) FROM `forum_thank` WHERE `userthank` = "' . $user_id . '" and `topic` = "' . $res['id'] . '" and `user` = "' . $res['user_id'] . '"');
$thankcheck = mysql_result($checkthank, 0);
if($thankcheck < 1 && $user_id != $res['user_id']) {
echo 'Yêu cầu phải thank bài viết';
} else {
echo '<a href="index.php?act=file&id=' . $fres['id'] . '">' . $fres['filename'] . '</a>';
}
}
?>


Tạo file .htaccess vào files/forum/attach
Thêm vào:

PHP Code:
<?php
Order Deny,Allow
Deny from all
?>



Xong
Nếu có lỗi hay bug lên diễn đàn thông báo nhé.
Nguồn @datplay
▲ Lượt xem: 86
- Share:
BBCode:

Link:
Cùng chuyên mục
Mod online ảo cho johncms
Modules lượt xem chuẩn cho JohnCMS
bbcode like mới thấy nội dung cho jonhcms
Tag Cloud đẹp mắt với TagCanvas - HTML5
Module No Avatar cho JohnCMS
Trang Chủ

The Soda Pop