vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   PHP parse_str() help needed (https://vborg.vbsupport.ru/showthread.php?t=224395)

nirvana43 10-02-2009 10:43 AM

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.

Lynne 10-02-2009 02:14 PM

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

nirvana43 10-02-2009 04:54 PM

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?

Lynne 10-02-2009 05:03 PM

$_GET['ac'] should be the variable name, I believe.

nirvana43 10-03-2009 01:05 AM

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!! :(


All times are GMT. The time now is 03:22 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.01047 seconds
  • Memory Usage 1,725KB
  • 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
  • (2)bbcode_code_printable
  • (2)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete