Installation Guide

(For the Attachment Mod to PunBB 1.2)

Ok, as some people seems to get some things messed up during install, I’ve decided to write this little installation guide to aid people in installing the mod “as good as possible”. It will hopefully save me debugging time later on 😉

Installing the mod on PunBB 1.2.6+ (Well, all new ones :))

There are a couple of things to note when installing on PunBB 1.2.6+. (Only for PunBB releases in the 1.2 series, the 1.3 will be different)

  • First of all, you need to edit install_mod.php to allow 1.2.XX. Where XX is the version you’re running (or it will just say it’s not the correct version when you try to run it)
  • Secondly, step 43 & 44 is altered. Just change the true to false after the query (and add the comment behind , so you have a mark that the attachment mod has altered that line)
  • Also, the linenumbers will be a bit off, so you probably need to search for the texts.
  • This mod suffers from the “poisoned NULL” vulnerability, to patch it replace the administrative plugin with the one named ““, that you find at PunBB Resource . (Only exploitable by administrators, but I still advice you to update the plugin)

Other than that it should be like installing for the 1.2.5 version.

Installing the mod on PunBB 1.2.5

  • Backup your database.
  • Backup the files in the webfolder (or at least the affected files: delete.php, edit.php, moderate.php, post.php and viewtopic.php)
  • Open up a browser and go to the project page at the PunBB Resource
  • Download the file called “” and save it on a place you’ll remember where you put it.
  • Download the languagefiles for all languages you have installed. If a language file is missing, scroll down to the bottom of this installation guide and read further instructions. It’s important that all languages have attach.php for them or the mod won’t work as it should.
  • Unzip the zipfiles, and unzip each languagefile to it’s own directory (as the files are named the same, do not overwrite!)
  • Now it’s time to create a directory where the files will go. Use the program you uploaded the forum in the first place, and create a directory that will hold all your uploaded files. A suggestion is to put it on a place where the browsers aren’t allowed to view, for security reasons. (if browsers are allowed to browse/download from that directory, it’s possible to find attachments with brute force (testing to download))
  • Now make sure the PHP script is allowed to upload files there, if you’re not sure what chmod to use, 777 is the one that will always work, but it would allow other people on the same server to get the files aswell, but if PHP runs as one user on the server, then it’s always possible to go through it to get to the attachments. If you don’t know what user PHP runs as, you can always check who owns the cache files in the forumroot/cache/ folder or in the forumroot/img/avatars/ folder. (there’s some issues that can happen with the chmod, so if you have problems look at the bottom of this for more info)
  • Open up and follow the readme.txt for the mod.
  • After you’ve followed the readme and ran install_mod.php successfully (if you have wrong chmod on the folder created in step 7, this is when you’ll know, go back and set the correct chmod, and run the install_mod.php again)
  • Now you need to upload all language attach.php files to each language directory.
  • Mod should be installed now.

Testing the mod

To test that the mod works, you are advised to do it in these simple 5 steps. If these works it’s probably installed correctly.

  • Create a small textfile in notepad with the text “test test test”, save it to disk as test.txt
  • As an administrator, login on the forum.
  • Click to create a new thread, enter some test text in the topic and textfield so you’re allowed to post. In the Attachment Mod file-field at the bottom, Click “browse” and select the file you created in step 1, and then post it.
  • Under the post, above the signature you should see that there’s one attachment, click on it to download it. Either save it or open it in notepad or similar.
  • If the text in the ‘downloaded’ file is the same as the text in the file you created, the mod seems to work.

Setup the mod

As default the mod has no rules for all normal users, and the max upload is only 2000 bytes (really tiny, most images today is larger in filesize). So you need to set a few variables and to set rules for all the groups that will be allowed to use the mod.

  • Open up the documentation for the mod chapter 1.6. Keep it open
  • As administrator on the forum, go to the administration page where you see some info of the version on PHP and the database. Next to the PHP information there’s a link “Show info”, click on that so you get to see the variables set for the webserver.
  • Read the documentation chapter 1.6 and find the variables in the page opened in step 2. Follow the documentation for how to figuring out how large attachments you can allow as a maximum.
  • Once you know what value you want on the max size for attachments, click “Attachment Mod” in the plugins area on the administration interface. Then click the “Alter settings” button for the mod. At the box for “Max filesize” enter the amount of bytes you want to allow as max upload.
  • Click “Update settings”
  • Now, it’s time to set the rules for all other people. Click on “List Rules” button on the Attachmen Mod plugin.
  • You see a list of who is allowed to do what in each forum. If the groupname is left out, they aren’t allowed to do that thing on that forum. For the forums you want to set rules, click “Edit rules for this forum”.
  • At the field “Create new ruleset” fill in the rules for a group you want to enable the mod for, click the boxes for what they are allowed to do, set the max upload (if set larger than “Max filesize” set in step 4, it’s automatically set the same as “Max filesize”). If you want to allow the users to add files to their posts during edit of the posts, you can increase the number of files per post. Lastly, if you only want to allow a specific list of files, enter the file suffix in the “Allowed files” area. If you want to write more than one, you need to use double quotationmarks to separate the filesuffixes. An example: txt”gif”jpg”jpeg”zip will allow a file called test.txt but not a file called test.txt.rar
  • Click “Create new ruleset”, and repeat from 6 to set rules as you like.

Create missing languagefiles.

There’s two ways, a quick and dirty or the proper way.

QnD way:

For the languages missing the attach.php lang file upload the english attach.php to the lang folder for the language missing the attach.php file.

Proper way:

  • Copy the english attach.php file to a new directory.
  • Open it with wordpad (or notepad, or any other text editor)
  • As you see there’s definitions on the left, and the language strings on the right side. The things on the right side (of =>) are the things that needs translating.
  • Translate the things on the right, and make sure you do not remove the %%ATTACHMENTS%% found on one of the lines. It’s replaced in the php script to the value of the number of attachments allowed.
  • If you want to leave info on who did the translation, you can put that info in the top of the file, but after the // Your name did this translation on a new row. The two // are crucial, as othervise the script will fail, // means the text after it is a comment, and PHP shouldn’t read it.
  • Upload the attach.php file to the correct language folder on the webserver
  • Optional (but I’d like it). Zip the file and send it on mail to me. (my email adress is in the readme.txt file for the mod) I’ll then upload it to Punres so other people can download it.

Leave a Reply

Your email address will not be published. Required fields are marked *