Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
  #1  
Old 10-02-2009, 10:43 AM
nirvana43's Avatar
nirvana43 nirvana43 is offline
 
Join Date: Oct 2007
Location: Pune, India
Posts: 361
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default PHP parse_str() help needed

Hello
I'm coding a mod for vb

I'm having problem with parse_str() function in following code block :

Quote:
foreach ($matched as $urls => $names)
{
parse_str($urls);
$temp=$ac;

//*****And then i'm printing values of $temp*********//

}
$urls contains following string data :

/sent?r345dfd32s&link=general&ac=3245534893783&status=waiting

I wanna store only numbers under "ac" in some string variable.

However, above code snippet results no data (blank) in $temp.
Is it because parse_str() is used within foreach() loop?
(I have to use it in foreach() because $urls contains different links everytime. Or is there any other way?)

If i remove foreach() loop then code works perfect.
Can any1 please help me with this??
You will get full credit in mod for solving this issue.
Reply With Quote
  #2  
Old 10-02-2009, 02:14 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You should use the vb cleaner:
PHP Code:
$vbulletin->input->clean_array_gpc('r', array(
    
'ac'      => TYPE_UINT,
)); 
And then you can set it this way:
PHP Code:
$temp $vbulletin->GPC['ac']; 
You should go read some of the articles regarding the vbulletin cleaner and making secure mods, like these - https://vborg.vbsupport.ru/showthrea...hlight=cleaner and https://vborg.vbsupport.ru/showthread.php?t=154411
Reply With Quote
  #3  
Old 10-02-2009, 04:54 PM
nirvana43's Avatar
nirvana43 nirvana43 is offline
 
Join Date: Oct 2007
Location: Pune, India
Posts: 361
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Actually i'm trying to do non vb thing in mod.
So there there is no global.php included.
And i dont think its reasonable to call global.php in script just for this reason.

Also the link i'm trying to parse is not fetched from actual url (the one in browser)
It is just a variable name i used.
So the actual string that has to be parsed is contained in $urls string variable.

How do i get that "ac" numbers?
Reply With Quote
  #4  
Old 10-02-2009, 05:03 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

$_GET['ac'] should be the variable name, I believe.
Reply With Quote
  #5  
Old 10-03-2009, 01:05 AM
nirvana43's Avatar
nirvana43 nirvana43 is offline
 
Join Date: Oct 2007
Location: Pune, India
Posts: 361
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think you didnt get what i'm trying to do here..
See, this data is not coming from any form etc.
The data is calculated/captured on runtime using preg_match() functions... Its CURL related things i'm doing in mod.
Following code is contained in $urls (Array).
Code:
/sent?r345dfd32s&link=general&ac=3245534893783&status=waiting
Everytime, "ac" and "r345dfd32s" things change for each array element.
However, i'm already having $urls (As a string for each index) the only thing is i wanna have "ac" numbers in some variable (For comparison purpose.. i'm not gunna echo 'em).
And yeah, i also tried with urldecode() etc.

The problem is, following code works perfect if i remove foreach() loop (i.e. it will b processing only 1 $urls)
Code:
parse_str($urls);
$temp=$ac;
When foreach() loop is added, above code ain't working...
So i guess (it may be stupid but still) parse_str() having hard time because of foreach().
The thing is, i googled a lot (and really a lot)... but i didnt find parse_str() written under foreach() loops anywhere.. but i also didnt find never to use parse_str() under foreach() written anywhere..
So i'm really really confused and stumped!!
Reply With Quote
Reply

Thread Tools
Display Modes

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 04:00 PM.


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.03751 seconds
  • Memory Usage 2,192KB
  • Queries Executed 11 (?)
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
  • (2)bbcode_code
  • (2)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete