Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 2.x > vBulletin 2.x Full Releases
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Details »»

Version: 1.00, by Admin (Coder) Admin is offline
Developer Last Online: Nov 2024 Show Printable Version Email this Page

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

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #32  
Old 06-06-2002, 10:20 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #33  
Old 06-06-2002, 11:31 AM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't think so, no.
Reply With Quote
  #34  
Old 06-06-2002, 12:27 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It was worth a shot, anyway. Thanks.

Quote:
Originally posted by FireFly
I don't think so, no.
Reply With Quote
  #35  
Old 06-06-2002, 01:29 PM
Slynderdale Slynderdale is offline
 
Join Date: Mar 2002
Location: New York State
Posts: 576
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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;
              }
            }
          }
        } 
Reply With Quote
  #36  
Old 06-06-2002, 01:32 PM
Slynderdale Slynderdale is offline
 
Join Date: Mar 2002
Location: New York State
Posts: 576
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #37  
Old 06-06-2002, 01:35 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #38  
Old 06-06-2002, 01:42 PM
Slynderdale Slynderdale is offline
 
Join Date: Mar 2002
Location: New York State
Posts: 576
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #39  
Old 06-06-2002, 01:47 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #40  
Old 06-06-2002, 01:54 PM
Slynderdale Slynderdale is offline
 
Join Date: Mar 2002
Location: New York State
Posts: 576
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #41  
Old 06-06-2002, 01:58 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You're way over my head on this one. I'll take your word for it.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:16 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04743 seconds
  • Memory Usage 2,331KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (9)bbcode_code
  • (1)bbcode_php
  • (5)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete