Blog literacki, portal erotyczny - seks i humor nie z tej ziemi
+--------------------------------------------------------------+
| Attachment Hack v2.5 |
+--------------------------------------------------------------+
| · Author: Satelk (satelk@hotmail.com), Osmodia (nimok@gmx.de) |
| · English version: Satelk (satelk@hotmail.com) |
| |
| · Description: This hack permits users to attach files |
| which are stored on the server. Permitted file |
| extensions and max. file size can be adjusted in |
| the admin cp. The fonction can also be completely |
| deactivated. In the posts, each file will be attributed |
| an icon for it's extension and the number of |
| downloads will be written next to the name of the |
| file. The attachment can also be deleted or changed |
| by those who have the right to edit that post. |
| |
| · Example: http://www.spscripts.com/forums |
| |
| · Written for: Burning Board 1.0 Beta 4.5 |
| |
| · Known Bugs: - |
| |
| · Planned: - Rank permissions (right to upload/download, |
| edit upload) |
| - different error messages |
+--------------------------------------------------------------+
+--------------------------------------------------------------+
| 1. Database changes |
+--------------------------------------------------------------+
To make the changes you can either execute attachment_hack.php
or update the database yourself.
? should be replaced by the board number
::MySQL db
create new table with 5 fields:
bb?_attachments:
attachmentid int(11) not null auto_increment primary index
userid int(11) not null 0
size int(11) not null 0
downloads int(11) not null 0
filename text not null
::MySQL db
insert 3 new fields at the end of the table:
bb?_config:
attachment int(1) not null 0
attachment_size int(11) not null 0
attachment_ext text not null
::MySQL db
insert 1 new field at the end of the table:
bb?_posts:
uploadid int(11) not null 0
+--------------------------------------------------------------+
| 2. Files to edit |
+--------------------------------------------------------------+
::board.php
search for:
$thread_link .= "";
Add UNDER it:
$upload = $db_zugriff->query("SELECT uploadid FROM bb".$n."_posts WHERE threadparentid='$threads[threadid]'");
$uploads = 0;
while ($row = $db_zugriff->fetch_array($upload)) {
if($row[uploadid] > 0) {
$uploads++;
}
}
if($uploads > 0) {
$thread_link .= "";
}
+--------------------------------------------------------------+
::search.php
search for:
$thread_link .= "";
Add UNDER it:
$upload = $db_zugriff->query("SELECT uploadid FROM bb".$n."_posts WHERE threadparentid='$threads[threadid]'");
$uploads = 0;
while ($row = $db_zugriff->fetch_array($upload)) {
if($row[uploadid] > 0) {
$uploads++;
}
}
if($uploads > 0) {
$thread_link .= "";
}
+--------------------------------------------------------------+
::edit.php
search for:
$post = $db_zugriff->query_first("SELECT boardparentid, threadparentid, userid, message, disable_smilies FROM bb".$n."_posts WHERE postid='$postid'");
replace with:
$post = $db_zugriff->query_first("SELECT boardparentid, threadparentid, userid, message, disable_smilies, uploadid FROM bb".$n."_posts WHERE postid='$postid'");
search for:
$db_zugriff->query("UPDATE bb".$n."_posts SET edittime='$time', editorid = '$editorid', message='$message', disable_smilies='$disablesmilies' WHERE postid='$postid'");
if($appendnote) $db_zugriff->query("UPDATE bb".$n."_threads SET timelastreply='$time' WHERE threadid='$threadid'");
eval ("\$output = \"".gettemplate("note8")."\";");
replace with:
if(($attachment_edit == 1) && $attachment && $user_file_name) {
$uploadid=uploadattachment($user_id,$attachment_ext);
if($uploadid==0) {
eval ("\$error = \"".gettemplate("newthread_error_attachment")."\";");
$uploaderror=1;
} else {
$attachmentchanged=", uploadid='$uploadid'";
$uploaderror=0;
if($post[uploadid]) deleteattachment($post[uploadid]);
}
}
if(($attachment_edit == -1) && $post[uploadid]) {
deleteattachment($post[uploadid]);
$attachmentchanged=", uploadid='0'";
}
if(!$uploaderror) {
$db_zugriff->query("UPDATE bb".$n."_posts SET edittime='$time', editorid = '$editorid', message='$message', disable_smilies='$disablesmilies'$attachmentchanged WHERE postid='$postid'");
if($appendnote) $db_zugriff->query("UPDATE bb".$n."_threads SET timelastreply='$time' WHERE threadid='$threadid'");
eval ("\$output = \"".gettemplate("note8")."\";");
}
search for:
else $edit_appendnote = "";
add UNDER it:
if($post[uploadid]) {
$attachmentinfo = $db_zugriff->query_first("SELECT * FROM bb".$n."_attachments WHERE attachmentid='$post[uploadid]'");
$attachment_filename=editDBdata($attachmentinfo[filename]);
$attachment_size_kb = round($attachmentinfo[size]/1024);
eval ("\$attachment_keep .= \"".gettemplate("edit_attachment_keep_1")."\";");
} else {
eval ("\$attachment_keep .= \"".gettemplate("edit_attachment_keep_2")."\";");
}
if($attachment) {
$attachment_ext_html = str_replace("\r\n"," ",$attachment_ext);
$attachment_size_kb = round($attachment_size/1024);
eval ("\$attachment_new .= \"".gettemplate("edit_attachment_new")."\";");
}
if($attachment || $post[uploadid]) eval ("\$attachmentbit .= \"".gettemplate("edit_attachmentbit")."\";");
+--------------------------------------------------------------+
::_functions.php
search for:
function delPost($postid,$threadid,$boardid) {
...
...
}
replace the complete function with:
function delPost($postid,$threadid,$boardid) {
global $n,$db_zugriff;
$threadinfo = $db_zugriff->query_first("SELECT replies FROM bb".$n."_threads WHERE threadid = '$threadid'");
$postinfo = $db_zugriff->query_first("SELECT userid,uploadid FROM bb".$n."_posts WHERE postid = '$postid'");
if($postinfo[uploadid]) deleteattachment($postinfo[uploadid]);
if(!$threadinfo[replies]) {
delUserposts($postinfo[userid]);
$db_zugriff->query("DELETE FROM bb".$n."_threads WHERE threadid='$threadid'");
$db_zugriff->query("DELETE FROM bb".$n."_posts WHERE postid='$postid'");
$pinfo = $db_zugriff->query_first("SELECT postid, posttime FROM bb".$n."_posts WHERE boardparentid = '$boardid' ORDER BY posttime DESC LIMIT 1");
$db_zugriff->query("UPDATE bb".$n."_boards SET threads=threads-1, posts=posts-1, lastposttime = '$pinfo[posttime]', lastpostid = '$pinfo[postid]' WHERE boardid = '$boardid'");
$db_zugriff->query("DELETE FROM bb".$n."_notify WHERE threadid='$threadid'");
$db_zugriff->query("DELETE FROM bb".$n."_poll WHERE threadid='$threadid'");
$db_zugriff->query("DELETE FROM bb".$n."_vote WHERE threadid='$threadid'");
$db_zugriff->query("DELETE FROM bb".$n."_object2user WHERE objectid='$threadid' AND favthreads = 1");
return 2;
} else {
delUserposts($postinfo[userid]);
$db_zugriff->query("UPDATE bb".$n."_threads SET replies=replies-1 WHERE threadid = '$threadid'");
$db_zugriff->query("DELETE FROM bb".$n."_posts WHERE postid='$postid'");
$pinfo = $db_zugriff->query_first("SELECT postid, posttime FROM bb".$n."_posts WHERE boardparentid = '$boardid' ORDER BY posttime DESC LIMIT 1");
$db_zugriff->query("UPDATE bb".$n."_boards SET posts=posts-1, lastposttime = '$pinfo[posttime]', lastpostid = '$pinfo[postid]' WHERE boardid = '$boardid'");
return 1;
}
}
search for:
function newPost($boardid,$threadid,$userid,$subject,$message,$posticon,$parseurl,$email,$disablesmilies,$signature,$close)
{
...
...
}
replace the complete function with:
function newPost($boardid,$threadid,$userid,$subject,$message,$posticon,$parseurl,$email,$disablesmilies,$signature,$close)
{
global $n,$db_zugriff,$attachment,$attachment_ext,$user_file_name;
$thread_info = $db_zugriff->query_first("SELECT boardparentid,flags FROM bb".$n."_threads WHERE threadid='$threadid'");
if($thread_info[flags]==1) return 2;
else {
if ($attachment && $user_file_name) {
$uploadid=uploadattachment($userid,$attachment_ext);
if($uploadid==0) $uploaderror=1;
} else $uploadid=0;
if (!$uploaderror) {
$time = time();
$subject = editPostdata($subject);
$message = editPostdata($message);
if($parseurl) $message = parseURL($message);
if($disablesmilies!=1) $disablesmilies=0;
if($signature!=1) $signature=0;
$db_zugriff->query("UPDATE bb".$n."_user_table SET userposts=userposts+1 WHERE userid='$userid'");
$db_zugriff->query("UPDATE bb".$n."_threads SET replies=replies+1, lastposterid='$userid', timelastreply='$time' WHERE threadid='$threadid'");
$ip = getenv(REMOTE_ADDR);
$db_zugriff->query("INSERT INTO bb".$n."_posts (boardparentid,threadparentid,userid,posttime,posttopic,message,posticon,disable_smilies,signature,ip,uploadid) VALUES ('$boardid','$threadid','$userid','$time','$subject','$message','$posticon','$disablesmilies','$signature','$ip','$uploadid')");
$postid = $db_zugriff->insert_id();
$db_zugriff->query("UPDATE bb".$n."_boards SET posts=posts+1, lastposttime = '$time', lastpostid = '$postid' WHERE boardid = '$boardid'");
sendEmail($userid,getLastPost($userid,5),$threadid,$boardid);
if($email && $userid) {
$check = $db_zugriff->query_first("SELECT COUNT(*) FROM bb".$n."_notify WHERE threadid = '$threadid' AND userid = '$userid'");
if(!$check[0]) $db_zugriff->query("INSERT INTO bb".$n."_notify VALUES ($threadid,$userid)");
}
if($close) $db_zugriff->query("UPDATE bb".$n."_threads SET flags = 1 WHERE threadid = '$threadid'");
return 4;
} else {
return 5;
}
}
}
add at the end of the file before ?>:
function uploadattachment($userid,$attachment_ext) {
global $db_zugriff,$n,$attachment_size,$user_file,$user_file_name,$user_file_size;
$userdir=str_pad($userid, 11, "0", STR_PAD_LEFT);
$uploadpath="attachments/".$userdir;
if (!is_dir($uploadpath)) { mkdir($uploadpath,0777); chmod ($uploadpath,0777); }
$attachment_ext = explode("\n", $attachment_ext);
for($i = 0; $i < count($attachment_ext); $i++) $attachment_ext[$i] = trim($attachment_ext[$i]);
$extension=substr(strrchr($user_file_name,"."),1);
if(!file_exists($uploadpath. "/" .$user_file_name) && in_array(strtolower($extension),$attachment_ext) && ($user_file_size <= $attachment_size)) {
$success=move_uploaded_file($user_file,$uploadpath."/".$user_file_name);
chmod ($uploadpath."/".$user_file_name,0777);
} else {
$success=0;
}
if($success) {
$user_file_name = editPostdata($user_file_name);
$db_zugriff->query("INSERT INTO bb".$n."_attachments (userid,size,downloads,filename) VALUES ('$userid','$user_file_size','0','$user_file_name')");
return $db_zugriff->insert_id();
} else {
return 0;
}
}
function deleteattachment($uploadid) {
global $db_zugriff,$n;
$attachment = $db_zugriff->query_first("SELECT filename,userid FROM bb".$n."_attachments WHERE attachmentid='$uploadid'");
unlink("attachments/".str_pad($attachment[userid], 11, "0", STR_PAD_LEFT)."/".editDBdata($attachment[filename]));
$db_zugriff->query("DELETE FROM bb".$n."_attachments WHERE attachmentid='$uploadid'");
}
+--------------------------------------------------------------+
::thread.php
search for:
unset($regdate);
add UNDER it:
unset($attachmentbit);
search for:
eval ("\$thread_postbit .= \"".gettemplate("thread_postbit")."\";");
add ABOVE it:
if($posts[uploadid]) {
$attachmentinfo = $db_zugriff->query_first("SELECT * FROM bb".$n."_attachments WHERE attachmentid='$posts[uploadid]'");
$attachment_filename=editDBdata($attachmentinfo[filename]);
$extension=strtolower(substr(strrchr($attachment_filename,"."),1));
if(!is_file("images/filetypes/".$extension.".gif")) $extension="unknown";
$attachment_size_kb = round($attachmentinfo[size]/1024);
if($extension == "gif" || $extension == "jpg" || $extension == "jpeg" || $extension == "bmp" || $extension == "png")
eval ("\$attachmentbit = \"".gettemplate("thread_attachimagebit")."\";");
else
eval ("\$attachmentbit = \"".gettemplate("thread_attachmentbit")."\";");
}
+--------------------------------------------------------------+
::newthread.php
search for:
if($user_id && !$userdata[avoidfc] && floodcontrol($user_id)) {
require("_board_jump.php");
eval("dooutput(\"".gettemplate("floodcontrol")."\");");
exit;
}
add UNDER it:
if ($attachment && $user_file_name) {
$uploadid=uploadattachment($user_id,$attachment_ext);
if($uploadid==0) {
eval ("\$error = \"".gettemplate("newthread_error_attachment")."\";");
$uploaderror=1;
}
} else $uploadid=0;
if(!$uploaderror){
search for:
$db_zugriff->query("INSERT INTO bb".$n."_posts (boardparentid,threadparentid,userid,posttime,posttopic,message,posticon,disable_smilies,signature,ip) VALUES ('$boardid','$nr','$user_id','$time','$subject','$message','$posticon','$disablesmilies','$signature','".getenv("REMOTE_ADDR")."')");
replace with:
$db_zugriff->query("INSERT INTO bb".$n."_posts (boardparentid,threadparentid,userid,posttime,posttopic,message,posticon,disable_smilies,signature,ip,uploadid) VALUES ('$boardid','$nr','$user_id','$time','$subject','$message','$posticon','$disablesmilies','$signature','".getenv("REMOTE_ADDR")."','$uploadid')");
search for:
header("Location: $ride");
exit;
add UNDER it:
}
search for:
eval("dooutput(\"".gettemplate("newthread")."\");");
add ABOVE it:
if($attachment) {
$attachment_ext_html = str_replace("\r\n"," ",$attachment_ext);
$attachment_size_kb = round($attachment_size/1024);
eval ("\$attachmentbit = \"".gettemplate("newthread_attachmentbit")."\";");
}
+--------------------------------------------------------------+
::reply.php
search for:
eval ("\$headinclude = \"".gettemplate("headinclude")."\";");
eval("dooutput(\"".gettemplate("action_ride")."\");");
exit;
replace with:
if($result==5) {
eval ("\$error = \"".gettemplate("newthread_error_attachment")."\";");
} else {
eval ("\$headinclude = \"".gettemplate("headinclude")."\";");
eval("dooutput(\"".gettemplate("action_ride")."\");");
exit;
}
search for:
eval("dooutput(\"".gettemplate("reply")."\");");
add ABOVE it:
if($attachment) {
$attachment_ext_html = str_replace("\r\n"," ",$attachment_ext);
$attachment_size_kb = round($attachment_size/1024);
eval ("\$attachmentbit = \"".gettemplate("newthread_attachmentbit")."\";");
}
+--------------------------------------------------------------+
::mod.php
search for:
$post_result = $db_zugriff->query("SELECT userid FROM bb".$n."_posts WHERE threadparentid='$threadid'");
replace with:
$post_result = $db_zugriff->query("SELECT userid,uploadid FROM bb".$n."_posts WHERE threadparentid='$threadid'");
search for:
delUserposts($row[userid]);
add UNDER it:
if($row[uploadid]) deleteattachment($row[uploadid]);
+--------------------------------------------------------------+
::misc2.php
add at the end of the file before ?>:
if($action == "download") {
$download = $db_zugriff->query_first("SELECT filename,userid FROM bb".$n."_attachments WHERE attachmentid=$attachmentid");
$db_zugriff->query("UPDATE bb".$n."_attachments SET downloads=downloads+1 WHERE attachmentid=$attachmentid");
$downloadurl=rawurlencode(editDBdata($download[filename]));
header("Location: attachments/".str_pad($download[userid], 11, "0", STR_PAD_LEFT)."/".$downloadurl);
}
+--------------------------------------------------------------+
::admin/admin.php
search for:
if($action == "post_options") {
...
...
}
replace the complete query with:
if($action == "post_options") {
if($send == "send") {
$anzahl_smilies = (int)($anzahl_smilies);
if(!$anzahl_smilies || !$cover || ($anzahl_smilies && round($anzahl_smilies/3)-($anzahl_smilies/3)!=0) || !$attachment_size) eval ("\$error = \"".gettemplate("error")."\";");
else $db_zugriff->query("UPDATE bb".$n."_config SET html = '$html', smilies = '$smilies', bbcode = '$bbcode', maximage = '$maximage', polls = '$polls', image = '$image', image_ext = '".editPostdata($image_ext)."', ch_parseurl = '$ch_parseurl', ch_email = '$ch_email', ch_disablesmilies = '$ch_disablesmilies', ch_signature = '$ch_signature', anzahl_smilies = '$anzahl_smilies', badwords = '".editPostdata($badwords)."', cover = '".editPostdata($cover)."', attachment = '$attachment', attachment_size = '$attachment_size', attachment_ext = '".editPostdata($attachment_ext)."'");
}
$info = $db_zugriff->query_first("SELECT html, smilies, bbcode, maximage, polls, image, image_ext, ch_parseurl, ch_email, ch_disablesmilies, ch_signature, anzahl_smilies, badwords, cover, attachment, attachment_size, attachment_ext FROM bb".$n."_config");
if(!$info[html]) $html_selected[0] = " selected";
else $html_selected[1] = " selected";
if(!$info[smilies]) $smilies_selected[0] = " selected";
else $smilies_selected[1] = " selected";
if(!$info[bbcode]) $bbcode_selected[0] = " selected";
else $bbcode_selected[1] = " selected";
if(!$info[polls]) $polls_selected[0] = " selected";
else $polls_selected[1] = " selected";
if(!$info[image]) $image_selected[0] = " selected";
else $image_selected[1] = " selected";
if(!$info[ch_parseurl]) $ch_parseurl_selected[0] = " selected";
else $ch_parseurl_selected[1] = " selected";
if(!$info[ch_email]) $ch_email_selected[0] = " selected";
else $ch_email_selected[1] = " selected";
if(!$info[ch_disablesmilies]) $ch_disablesmilies_selected[0] = " selected";
else $ch_disablesmilies_selected[1] = " selected";
if(!$info[ch_signature]) $ch_signature_selected[0] = " selected";
else $ch_signature_selected[1] = " selected";
if(!$info[attachment]) $attachment_selected[0] = " selected";
else $attachment_selected[1] = " selected";
$image_ext = editDBdata($info[image_ext]);
$badwords = editDBdata($info[badwords]);
$cover = editDBdata($info[cover]);
$maximage = $info[maximage];
$anzahl_smilies = $info[anzahl_smilies];
$attachment_size = $info[attachment_size];
$attachment_ext = editDBdata(strtolower($info[attachment_ext]));
eval("dooutput(\"".gettemplate("post_options")."\");");
}
+--------------------------------------------------------------+
| 3. Templates |
+--------------------------------------------------------------+
::admin/templates/post_options.htm
search for:
add ABOVE it:
Size in Bytes (1 kb = 1024 Bytes 1 MB = 1048576 Bytes); the size should not be higher than the server's max. value for PHP uploads.
(one per line)
Extensionss can be assigned certain Icons, by creating the appropriate file 'images/filetypes/EXTENSION.gif'
+--------------------------------------------------------------+
::templates/edit.htm
search for:
add ABOVE it:
$attachmentbit
search for:
replace with:
+--------------------------------------------------------------+
::templates/newthread.htm
search for:
add ABOVE it:
$attachmentbit
search for:
replace with:
+--------------------------------------------------------------+
::templates/reply.htm
search for:
add ABOVE it:
$attachmentbit
search for:
replace with:
+--------------------------------------------------------------+
::templates/thread_postbit.htm
search for:
$signature
add BEHIND it:
$attachmentbit
+--------------------------------------------------------------+
| 4. File upload/other |
+--------------------------------------------------------------+
::templates
Upload all enclosed htm file into your templates directory !
+--------------------------------------------------------------+
::images
Upload the complete content of the 'images' directory in the 'images' directory;
add images files for other extensions if necessary.
+--------------------------------------------------------------+
::/
In the wbboard directory(or where your php files are),
create a new directory called 'attachments' and chmod it 777.
+--------------------------------------------------------------+
::
Go make the appropriate changes in the control panel.
You're done!
Darmowy hosting zapewnia PRV.PL