Version: 1.00, by Admin (Coder)
Developer Last Online: Nov 2024
Version: 2.2.x
Rating:
Released: 01-29-2002
Last Update: Never
Installs: 7
No support by the author.
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.
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:
Code:
[high] $editattach='';[/high]
right before this:
Code:
if ($post[attachmentid]!=0 and $post[attachmentvisible]) {
And add this:
Code:
[high] 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>)';
}[/high]
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)?
Quote:
Originally posted by FireFly You can't look into the browser's computer with PHP.
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
PHP Code:
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;
}
}
}
}
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
I'd be very interested in seeing it when you are done.
Quote:
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
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