View Full Version : Attachment Editor
Admin
01-29-2002, 10:00 PM
This one gives users a way to edit their attached text (.txt) files inside the forum system, without the hassle of downloading-editing-updating the file every time. :)
(needless to say only mods and the poster can see the link / access the editor)
I thought of it while updating a hack of mine, because I had to do it numerous times and it really got on my nerves. :o
If you want to see a demo, either attach a small file here and see how it works, or just look below in the next post for a screen shot. :)
(the image is also in the zip file)
Anyhow, here are the instructions to install the hack.
First download the attached zip archive so you can have the files you need in front of you.
A text version of this post is available in the zip as well.
In functions.php, add this:
$editattach='';
right before this:
if ($post[attachmentid]!=0 and $post[attachmentvisible]) {
And add this:
if (($bbuserinfo['usergroupid']==5 or $bbuserinfo['usergroupid']==6 or $bbuserinfo['usergroupid']==7 or $bbuserinfo['userid']==$post['userid']) and $post['attachmentextension']=='txt') {
$editattach=' (<a href="misc.php?s=&action=editattach&postid='.$post['postid'].'">edit</a>)';
}
right before this:
eval("\$post[attachment] = \"".gettemplate("postbit_attachment")."\";");
}
} else {
$post[attachment]="";
}
Save functions.php and upload.
In misc.php, add the contents of add-to-misc.txt (in attached zip file) right before ?> (end of file).
Save misc.php and upload.
In the postbit_attachment template add this:
$editattach
right after this:
$post[filename]</a>
Create a new template editattach with the contents of editattach.txt (in attached zip file).
Add a new template error_attacheditorinvalidext:
You are trying to edit a file with an invalid extension. We currently only support editing text files.
Add a new template error_attacheditortoobig:
The data you are trying to save is too big! The maximum allowed size is $maxattachsize bytes.
Add a new template redirect_attachupdated:
The attachment has been updated! You will now be taken back to your post.
Have fun! :china:
Admin
01-30-2002, 11:41 AM
A screen shot...
larryz
01-30-2002, 11:54 AM
Excellent idea FireFly, I'm going to check this one out ASAP.
Lesane
01-30-2002, 11:56 AM
Great hack, Thanks.
SaintDog
01-30-2002, 09:19 PM
Nice hack, although I am using 2.2.1 because I do not feel like re-applying 20 hacks to the board when almost every file has been edited in some way or another.
From the looks of it though, it would be a great tool, not only for those here, but many others as well.
Great job!
Lesane always is the first or second person that replies to a new hack post, and always replies "Great hack, thanks" :D
But in all seriousness chen, great hack, thanks! :D:D
Lesane
01-31-2002, 09:25 AM
Originally posted by Dade
Lesane always is the first or second person that replies to a new hack post, and always replies "Great hack, thanks" :D
But in all seriousness chen, great hack, thanks! :D:D
haha :D, tru tru but only when its a great hack though ;)
MikeWarner
01-31-2002, 09:49 AM
Just testing to see it work.....
MikeWarner
01-31-2002, 09:50 AM
wow - very nice. I like that! Don't think I'll need it on my site though as only admin can attach files, and they are always .gif files.
Nice work though.
Danny
02-03-2002, 11:25 PM
testing also
Danny
02-03-2002, 11:51 PM
I dont seem to be able to get this to work, i done everything, been through it twice and double checked it also.
and i still dont get the edit bit after the attachment :( any ideas ?
got vb 2.2.2
Admin
02-04-2002, 01:15 PM
Only seen after .txt files, Danny.
Are you sure you uploaded the files as well? (sounds basic but you'd be surprised how many people skip that step :D)
Lucky
02-05-2002, 03:00 AM
working good for me.
Thanks
Preasidium
05-13-2002, 04:45 AM
i tryed to install this as well. I get the link but it points to a blank page. Nothing on it. I even went threw all the codes and changes all .php to .php3 ( because thats what I use ).
Any suggestions on what to do?
Admin
05-13-2002, 11:00 AM
Have you edited misc.php correctly?
Preasidium
05-13-2002, 12:36 PM
Yes i have. I added what I had to. And changed global.php to php3 ofcource. But I will re do it. And see if I can see what I did wrong. But thats the only problem right? The misc.php3? Because I see the link and everything just nothing in my misc.php3 when I click the link..
Preasidium
05-13-2002, 01:05 PM
ok i redid it. This time im getting this error
Fatal error: Call to undefined function: adminlog() in /home/fatali/public_html/VB-Home/misc.php3 on line 13
Even tho i didnt touch no where near that line.
proton242
05-13-2002, 06:53 PM
work also with .nfo files?
Boofo
05-19-2002, 05:35 AM
How about adding the ability to turn word wrap on or off in the editor? :)
Boofo
05-22-2002, 06:09 AM
Firefly,
Maybe next time you should tell us WHICH misc.php to edit. :) I got it straightened out after editing the wrong one. I was getting the same things going on as Preasidium, where when I hit edit, it gave me a blank page. Once I took it out of the admin/misc.php and put it in the root/misc.php, you'd be surprised at how well it worked. :) Great hack, though! Looking forward to more! :)
BTW: Admins, Supermods and Mods can edit the file, right? Will it also not increase the download counter for those 3? It doesn't seem to and I wanted to make sure it was supposed to do that. Also, I had to clean my cache for the edited file to show up. Is that normal and if so, is there anyway to fix that so we don't have to clean the cache everytime to check it while viewing?
Boofo
05-31-2002, 11:49 PM
I had the attachment editor working great. I just installed the attachments as files hack and now the attachment editor comes up ok, but the file is empty in editing mode. In view mode, the whole file is there. I doubled checked everything and I have found 2 instances of the code where I need to add the usergroupid code. I tried taking one of them out and that just makes it worse. Has anyone else run into this problem? Can someone please help me on this?
Admin
06-01-2002, 06:39 AM
This hack won't work with attachments as files.
Boofo
06-01-2002, 08:13 AM
I guess we know which one is going to have to go then, huh? I'm keeping the attachment editor. :) Thanks Chen. :)
Admin
06-01-2002, 08:30 AM
Really? I would expect you to keep the other hack, it seems more important to users that really need it.
Boofo
06-01-2002, 09:24 AM
It's really not as important to me as the flexibility of an editor, to tell you the truth. The option of being able to edit something on the fly instead of having to reupload it is much more important to me. And I have always gone by the philosophy that if I install a hack that causes problems with another one, that hack has got to go. :) I think the files in the db are more secure than having them on your server, anyway, aren't they? :) I'm sticking with what works.
Originally posted by FireFly
Really? I would expect you to keep the other hack, it seems more important to users that really need it.
Mone'
06-01-2002, 09:30 AM
Originally posted by Boofo
............I think the files in the db are more secure than having them on your server, anyway, aren't they? :) .........
Boofo the attachment on the server are very secure if you can place the directory above your www
there is no way that anyone could get them from they're browser
I think having the attachment as file is great especially down the track when you want to back up the db and you have 1000's of attachment :)
immagine the file size of that !
anyhow go with what you like ;D
Just my 2 cents
Mone'
Boofo
06-01-2002, 09:38 AM
You could be right about the security. I'm too new at all of this to know for sure. :)
As far as down the road on backing up goes, I don't have that much yet and I'm sure when it gets to the point that I would ever need it, someone will come up with a hack to extract attachments form the db for backing up purposes and then make it so they can re-insert them once the db is re-installed (unless they already have something like that and I missed it).
The editor is something I will use more now. And also, this is the very first hack I have ever installed that caused another one to stop working completely. Can't be havin' that now, can we? ;)
Originally posted by Mone'
Boofo the attachment on the server are very secure if you can place the directory above your www
there is no way that anyone could get them from they're browser
I think having the attachment as file is great especially down the track when you want to back up the db and you have 1000's of attachment :)
immagine the file size of that !
anyhow go with what you like ;D
Just my 2 cents
Mone'
Tarion
06-03-2002, 12:26 AM
hghjg
Boofo
06-05-2002, 04:19 PM
Chen,
Instead of having to clean the cache when we make an update to the file, is there any way to be able to look into the cache directory for that file and erase it first before we download (view) the updated one? Wouldn't that handle the cache problem? :)
Admin
06-06-2002, 08:31 AM
You can't look into the browser's computer with PHP. :)
Boofo
06-06-2002, 10:20 AM
Thanks, Chen, at least now I know not to look in that direction. How about CGI or HTML? In your opinion, can it be done with either one of those (before I start digging into it and finding out the same)? :)
Originally posted by FireFly
You can't look into the browser's computer with PHP. :)
Admin
06-06-2002, 11:31 AM
I don't think so, no.
Boofo
06-06-2002, 12:27 PM
It was worth a shot, anyway. Thanks. :)
Originally posted by FireFly
I don't think so, no.
Slynderdale
06-06-2002, 01:29 PM
hmm, i was trying to fix the permission up becayse the way you have it, it lets any moderator, super moderator, admin and the one who posted it edit it, im trying to make it so it checks the users permission first and see if they are a moderator in the forum or have the editpost permission and if there the one that posted it, if there not, they cant see the edit link or edit the file but i cant seem to get it to work, i tried using this
if (!isset($postid)) {
$postinfo=$DB_site->query_first("SELECT postid FROM post WHERE attachmentid=$attachmentid");
$postid=$postinfo[postid];
}
$postinfo=getpostinfo($postid);
$threadinfo=getthreadinfo($postinfo[threadid]);
$getperms=getpermissions($threadinfo[forumid]);
if (!ismoderator($threadinfo[forumid],"caneditposts")) { // check for moderator
if (!$threadinfo[open]) {
eval("standardredirect(\"".gettemplate("redirect_threadclosed")."\",\"showthread.php?s=$session[sessionhash]&threadid=$threadinfo[threadid]\");");
exit;
}
if (!$getperms[caneditpost]) {
show_nopermission();
} else {
if ($bbuserinfo[userid]!=$postinfo[userid]) {
// check user owns this post
show_nopermission();
} else {
// check for time limits
if ($postinfo[dateline]<(time()-($edittimelimit*60)) and $edittimelimit!=0) {
eval("standarderror(\"".gettemplate("error_edittimelimit")."\");");
exit;
}
}
}
}
Slynderdale
06-06-2002, 01:32 PM
thats the only problem im having, after i get this fix, im gonna add a field in the admin options under attachments where you can specify what attachment files can be edited with it, like txt php nfo and so on
Boofo
06-06-2002, 01:35 PM
I'd be very interested in seeing it when you are done. :)
Originally posted by Slynderdale
thats the only problem im having, after i get this fix, im gonna add a field in the admin options under attachments where you can specify what attachment files can be edited with it, like txt php nfo and so on
Slynderdale
06-06-2002, 01:42 PM
Originally posted by Boofo
I'd be very interested in seeing it when you are done. :)
when im done ill release it for every one, also a edit so it works with saving attachments as files too, for those who have that installed
Boofo
06-06-2002, 01:47 PM
looking forward to it. Scott just got his Attachments as Files hack working with Chen's attachment editor, so you picked a good time to release it. :)
Slynderdale
06-06-2002, 01:54 PM
Originally posted by Boofo
looking forward to it. Scott just got his Attachments as Files hack working with Chen's attachment editor, so you picked a good time to release it. :)
wouldnt be hard to do, if its a editable file just have it open the file like they have it with avatars on other websites, read the data inside and store it as a varible
Boofo
06-06-2002, 01:58 PM
You're way over my head on this one. :) I'll take your word for it. :)
Admin
06-06-2002, 02:52 PM
Just uploaded a new file, so the hack is now compatible with PPN's Attachments as Files hack. :) Thanks Scott.
Boofo
06-06-2002, 03:02 PM
You mean it IS now compatible, right? :) I got the file from Scott yesterday and it works Great! :) Thanks to you, Chen AND Scott for both great hacks! :):):)
Originally posted by FireFly
Just uploaded a new file, so the hack is not compatible with PPN's Attachments as Files hack. :) Thanks Scott.
Slynderdale
06-07-2002, 04:37 AM
nevermind every one, fixed it myself :)
Boofo
06-07-2002, 05:34 AM
Will this work with both the attachment editor AND attachments as files hacks? And when are you going to release it? It looks like what I am looking for. :)
Originally posted by Slynderdale
nevermind every one, fixed it myself :)
Dark Shogun
09-10-2002, 05:21 PM
I installed the hack but when I try to edit the txt file I get a blank white page. :( Does anyone know how to fix this?
Dark Shogun
Dark Shogun
09-12-2002, 05:31 PM
Problem fixed. Put info in wrong misc.php Works great now.
Dark Shogun
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.