Quote:
Originally Posted by sv1cec
I read the above, but still in the code, there are instances that vBulletin uses $_REQUEST.
Can someone shed some light on this? Based on the above, I changed a program to use $vbulletin->GPC instead of $_REQUEST and the program no longer works. Switched back to $_REQUEST and everything works fine.
I am puzzled.
I think I need to elaborate:
In the past, I was using this part of code:
PHP Code:
// ########################## REDIRECT ############################### if ($_REQUEST['do'] == 'nextstep') { globalize($_REQUEST, array( 'action' => STR, 'done' => STR )); if (empty($action)) { define('CP_REDIRECT', THIS_SCRIPT . '.php'); } else { define('CP_REDIRECT', THIS_SCRIPT . '.php?step=' . $action); } print_stop_message('redirecting_please_wait'); }
Now, the code has to be changed to:
PHP Code:
if ($_REQUEST['do'] == 'nextstep') {
$vbulletin->input->clean_array_gpc('r', array( 'action'=> TYPE_STR, 'done'=> TYPE_STR, ));
if (empty($vbulletin->GPC['action'])) { define('CP_REDIRECT', THIS_SCRIPT . '.php'); } else { define('CP_REDIRECT', THIS_SCRIPT . '.php?step=' . $vbulletin->GPC['action']); } print_stop_message('redirecting_please_wait'); }
I found this after a lot of trials and errors. What's the reason for having to check for $_REQUEST['do'] in the first if, and then use $vbulletin->GPC in the next parts? Where do I use $_REQUEST and where $vbulletin->GPC????
|
Do this instead to avoid that situation:
PHP Code:
$vbulletin->input->clean_array_gpc('r', array(
'do' => TYPE_STR,
'action'=> TYPE_STR,
'done'=> TYPE_STR)
);
if ($vbulletin->GPC['do'] == 'nextstep'){
if (empty($vbulletin->GPC['action'])){
define('CP_REDIRECT', THIS_SCRIPT . '.php');
} else {
define('CP_REDIRECT', THIS_SCRIPT . '.php?step=' . $vbulletin->GPC['action']);
}
print_stop_message('redirecting_please_wait');
}
This effectively puts the $_REQUEST['do'] into the GPC, thus removing the need for the call to any $_REQUESTs. Of course, if you are only using the $_REQUEST['do'] to navigate through your script and not calling anything else, then you can leave the $_REQUEST calls and it will remove some overhead according to KirbyDE when I asked basically the same question.