Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 04-18-2005, 08:53 PM
Lionel Lionel is offline
 
Join Date: Dec 2001
Location: Delray Beach, Florida
Posts: 3,277
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Mystery file

I am trying to create my very first hack which is adding a description with attachment. Since nothing gets updated at posting time, I tried to do a view source to see if the value was parsed.... And guess what? The view source does not show the existence of attachment!!!! Where is that file??? Even here at vb.org, I cannot view the source of attachment that I just uploaded while in newthread.php

I can only see the line about valid extensions, then right after, the line for "manage attachments". The in between remains a mystery.
Attached Images
File Type: jpg Image1.JPG (101.4 KB, 0 views)
Reply With Quote
  #2  
Old 04-18-2005, 09:14 PM
Link14716's Avatar
Link14716 Link14716 is offline
 
Join Date: Jun 2002
Location: Georgia, USA
Posts: 2,519
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm pretty sure it is done by JavaScript.
Reply With Quote
  #3  
Old 04-18-2005, 09:19 PM
Lionel Lionel is offline
 
Join Date: Dec 2001
Location: Delray Beach, Florida
Posts: 3,277
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I managed to locate it in newattachment.php. Now it's a matter of inserting that description into the newly created field in attachment table.
Reply With Quote
  #4  
Old 04-18-2005, 09:20 PM
akanevsky akanevsky is offline
 
Join Date: Apr 2005
Posts: 3,972
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
I'm pretty sure it is done by JavaScript.
It is so.
If you turn off javascript, you won't be able to see anything in the place of that screenshot. Therefore, the best place to create the option that would enable users to enter attachment descriptions is the upload screen .

What you would need is:
A template change;
A new button (update description information)
A php file modification that would update the attachment record

Pretty easy.
Reply With Quote
  #5  
Old 04-18-2005, 09:25 PM
Lionel Lionel is offline
 
Join Date: Dec 2001
Location: Delray Beach, Florida
Posts: 3,277
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I called the textarea field :

name="caption" value="$attach[caption]"

and in functions_newpost.php, I did:

Quote:

// now update the attachments .. if we have any visible OR not, otherwise the hourly cleanup will wipe them out

if ($totalattachments)



$caption = '';
{


$DB_site->query("

UPDATE " . TABLE_PREFIX . "attachment

SET postid = $post[postid], posthash = '', caption = $attach[caption]

WHERE posthash = '" . addslashes($post['posthash']) . "'

AND userid = $bbuserinfo[userid]

");

That gives me a database error
Reply With Quote
  #6  
Old 04-18-2005, 09:40 PM
akanevsky akanevsky is offline
 
Join Date: Apr 2005
Posts: 3,972
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Of course it does. This is really improper use of MySQL... And I really think that before writing your applications, you should read the tutorial and security tips.

However, I appreciate you trying to be creative, so there you go:
1. In MySQL queries, always enclose values into single quotes ('). That is how the script knows, where the string starts and where it ends.
2. In MySQL queries, when there is user input that cannot be validated, always use addslashes function.

Therefore, the correct query would be:

Code:
$DB_site->query("

UPDATE " . TABLE_PREFIX . "attachment

SET postid = $post[postid], posthash = '', caption = '" . addslashes($attach[caption]) . "'

WHERE posthash = '" . addslashes($post['posthash']) . "'

AND userid = $bbuserinfo[userid]

");
Note: I used double quotes (") to escape from the string and to be able to use the addslashes function Good luck with the rest.
Reply With Quote
  #7  
Old 04-18-2005, 09:51 PM
Lionel Lionel is offline
 
Join Date: Dec 2001
Location: Delray Beach, Florida
Posts: 3,277
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, that got rid of the database error, but it did not go anywhere. Table attachment.caption did not get updated.

Maybe I should do it:
caption = '" . addslashes($_POST[caption])
Reply With Quote
  #8  
Old 04-18-2005, 09:54 PM
akanevsky akanevsky is offline
 
Join Date: Apr 2005
Posts: 3,972
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes. I do not know what is the HTML name of you control, but if it is "caption", then yes More correct way would be $_POST['caption'] though

Also (but don't worry about it, you can add it when you develop the hack), you should globalize the caption variable through vbulletin's globalize array, then you can just access it as $caption
Reply With Quote
  #9  
Old 04-18-2005, 10:04 PM
Lionel Lionel is offline
 
Join Date: Dec 2001
Location: Delray Beach, Florida
Posts: 3,277
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I give up. It does not insert anywhere in attachment table.

Thanks for your help. Right now, If you go on my homepage you will see that I am able to put a description under image. Problem with current method, it uses $post[caption] and inserts value in post. So if there are more than image in post, it inserts same description for all.
Reply With Quote
  #10  
Old 04-18-2005, 10:22 PM
akanevsky akanevsky is offline
 
Join Date: Apr 2005
Posts: 3,972
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Maybe you should use something like $attachment[caption] ? :P

Iight, you are editing the completely wrong query, so trace back all the changes. If you want, I can write that hack...
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 11:27 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.05942 seconds
  • Memory Usage 2,266KB
  • Queries Executed 14 (?)
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
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (1)postbit_attachment
  • (10)postbit_onlinestatus
  • (10)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_postinfo_query
  • fetch_postinfo
  • 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_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete