vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   Attachment Editor (https://vborg.vbsupport.ru/showthread.php?t=34625)

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:
    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]

    right before this:
    Code:

                            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:
    Code:

    [high]$editattach[/high]
    right after this:
    Code:

    $post[filename]</a>
  • Create a new template editattach with the contents of editattach.txt (in attached zip file).
  • Add a new template error_attacheditorinvalidext:
    Code:

    [high]You are trying to edit a file with an invalid extension. We currently only support editing text files.[/high]
  • Add a new template error_attacheditortoobig:
    Code:

    [high]The data you are trying to save is too big! The maximum allowed size is $maxattachsize bytes.[/high]
  • Add a new template redirect_attachupdated:
    Code:

    [high]The attachment has been updated! You will now be taken back to your post.[/high]

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!

Dade 01-31-2002 12:20 AM

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

Quote:

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.

Quote:

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

Quote:

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? ;)

Quote:

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)? :)

Quote:

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. :)

Quote:

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
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;
              }
            }
          }
        } 


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. :)

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

Slynderdale 06-06-2002 01:42 PM

Quote:

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

Quote:

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. :)


All times are GMT. The time now is 02:46 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01269 seconds
  • Memory Usage 1,837KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (9)bbcode_code_printable
  • (1)bbcode_php_printable
  • (9)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete