MyBB Community Forums

Full Version: {Please help} What is the best way to do -->this (which should be easy) With MyBB...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
EDIT: The question still applies for situations where you have more than one variable; One variable is easy (see my third post for more details about passing one variable)

Hi,
What is the best way to do -->this (which should be easy) With MyBB and php?
  • Easy way to pass a variable through "error_no_permission();"?
define('IN_MYBB', 1);
require_once './global.php';

if($mybb->user['uid']) {
} else {	
 error_no_permission();
} 

$return10= $_REQUEST["return10"];
echo $return10;
echo "You are logged in!";

--> If (I am logged in at the start)
then both the variable and the phrase are set and do 'echo' properly.

--> If (I am Not logged in at the start)
then only the phrase is set and will 'echo', after successful login.

Solution?
Passing the variable through the "error_no_permission" template is a start; then what?
Modify member.php / To accept and pass the variable? Dodgy
Write a small plugin just to pass a variable?

What is the best way to do -->this (which should be easy) With MyBB and php?
Please give advice if you can, thank you.
What exactly are you trying to do?
This variable "$return10= $_REQUEST["return10"];" (for example) is available to any end user who was already logged in when landing on the page; When the 'error_no_permission();' function kicks in, then the $_REQUEST["return10"]; variable is no longer set, after logging in.

(2010-06-27, 07:40 AM)Tommyk Wrote: [ -> ]What exactly are you trying to do?

#
Short answer:
error_no_permission(); --> posts login data to --> member.php --> redirects to original page.
^^^
I need the best way to go through all of that (above), and still have a variable...
$example1= $_REQUEST["example1"];
...be usable.
Honestly, no idea :s
(2010-06-27, 08:26 AM)Tommyk Wrote: [ -> ]Honestly, no idea :s

Thanks anyway Tommy, I'm making progress....

Anyone have time to report a bug?

<input type="hidden" name="url" value="/ssl/a_salt2.php?return10=http://example.com/bb/calendar.php&amp;var2=example2&amp;var3=example3" />

#
What's wrong with this part here?
value="/ssl/a_salt2.php?return10=http://example.com/bb/calendar.php&amp;var2=example2&amp;var3=example3"
^^^
That code is from "view source" of a page w/ a MyBB 'error_no_permission();' message.

The original url is more like this:
/ssl/a_salt2.php?return10=http://example.com/bb/calendar.php&var2=example2&var3=example3*

So...
  • Following login only the first variable is available, since the first "&amp;", and everything beyond it, gets cut off from the url, after login.
I'm not sure if you understand what error_no_permission() does.
First it does not accept any arguments.
And second it outputs an error page which says "You do not have permission to access this page bla bla bla", it does not validate anything.

But I do not understand what you're trying to do.
if your users are going somewhere they have no permission to be, simply give them the message via error_no_permission() and then let them use the back button to get back to where they came from.

it looks like you are trying to do a 'you will now be taken back to where you came from' type deal after logging in, correct? so if a user is on page and wants to do something but is not logged in, they can login from that page and once logged in, will be redirected back to the page they logged in from?

or at least something similar to that?
What you're trying to do cannot be accomplished. As stated, error_no_permission accepts no arguments, therefore cannot be changed.

Try error() instead.

http://mybb.com/sourcedocs/MyBB/_inc---f...ctionerror
(2010-06-27, 10:34 AM)Pirata Nervo Wrote: [ -> ]I'm not sure if you understand what error_no_permission() does.
First it does not accept any arguments....

...But I do not understand what you're trying to do.

I do know what error_no_permission() does.
Please see below for a better explanation.

(2010-06-27, 03:23 PM)pavemen Wrote: [ -> ]...will be redirected back to the page they logged in from?

or at least something similar to that?

You are close pavemen, the return variable is part of a bigger script; Simplified here to show just the part I need fixed, thanks.

(2010-06-28, 05:19 AM)Ryan Ashbrook Wrote: [ -> ]What you're trying to do cannot be accomplished. As stated, error_no_permission accepts no arguments...


OK:
pass a variable through error_no_permission(); was obviously a poor choice of words, but the idea Lightbulb is not that hard to understand:

Below is a custom page, simplified to show the part I need to fix.
define('IN_MYBB', 1);
require_once './global.php';
if($mybb->user['uid']) {
} else {	
 error_no_permission(); } 

$return10= $_REQUEST["return10"];
echo $return10;
echo "You are logged in!";

--> If (I am logged in at the start)
then both the variable and the phrase are set and do 'echo' properly.

--> If (I am Not logged in at the start)
then only the phrase is set and will 'echo', after successful login.
The variable is no longer set.** ((please, see part 2, actually one variable is still set))

1) Surely, by now someone must understand the question, right?
2) What is the answer?

##

part 2:

EDIT:
Almost forgot....
My third post shows a bug with MyBB
What's wrong with this part here? 
((( This is part of the "view source" code of the 'no permission' login form  )))
value="/ssl/a_salt2.php?return10=http://example.com/bb/calendar.php&amp;var2=example2&amp;var3=example3"

&amp; gets put (or converted by the browser) into the*...
<input type="hidden" name="url" value="*here...
when & should be there instead


###

Try again:
One variable is still available to use $example1= $_REQUEST["example1"]; The rest of the query string is cut off (see part 2 as to why)

So...
  • For more than one variable:
1) error_no_permission(); -->
2) Brings up login form -->
3) posts login data to -->
4) member.php -->
5) redirects to original page.
^^^
I need the best way to go through all of that (above), and still have another variable...
PHP Code:
$example2= $_REQUEST["example2"];
...be set and usable.
  • Obviously can be done with a plugin, is there another way?
Thanks