DragonPrime - LoGD Resource Community
Welcome Guest
  • Good morning, Guest.
    Please log in, or register.
  • January 20, 2018, 01:14:54 AM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1]   Go Down
  Print  
Author Topic: $_GET['op'] in forest special event  (Read 3568 times)
0 Members and 1 Guest are viewing this topic.
Excalibur
Member
Mod God
*****
Offline Offline

Posts: 573


I'm a newbie, plz forgive me!


View Profile WWW
« on: February 17, 2006, 02:27:16 PM »

It's been a long time I was wondering why some special event had problem running if they use $_GET['op'] instead of $HTTP_GET_VARS['op'].

Finally, thanks to a user of my server, I've found out the reason.

Open forest.php and find:
Code:
                  $y = $HTTP_GET_VARS[op];
                  $HTTP_GET_VARS[op]="";
                  include("special/".$events[$x]);
                  $HTTP_GET_VARS[op]=$y;
Replace the whole block of code with this one:
Code:
                  $y = $HTTP_GET_VARS[op];
                  $yy = $_GET['op'];
                  $HTTP_GET_VARS[op]="";
                  $_GET['op']="";
                  //include("special/".$events[$x]);
                  @(include("special/".$events[$x])) or redirect("forest.php"); this one 'cause sometimes I get en error calling special
                  $HTTP_GET_VARS[op]=$y;
                  $_GET['op'] = $yy;
With this correction you won't get anymore problems with your specials.

Have fun
Excalibur
Logged

Spock: Random chance seems to have operated in our favor.
McCoy: In plain, non-Vulcan English, we've been lucky.
Spock: I believe I said that, Doctor.
Eliwood
Member
Codemeister
****
Offline Offline

Posts: 271


View Profile WWW
« Reply #1 on: February 17, 2006, 03:58:03 PM »

It's been a long time I was wondering why some special event had problem running if they use $_GET['op'] instead of $HTTP_GET_VARS['op'].

Finally, thanks to a user of my server, I've found out the reason.

Open forest.php and find:
Code:
                  $y = $HTTP_GET_VARS[op];
                  $HTTP_GET_VARS[op]="";
                  include("special/".$events[$x]);
                  $HTTP_GET_VARS[op]=$y;
Replace the whole block of code with this one:
Code:
                  $y = $HTTP_GET_VARS[op];
                  $yy = $_GET['op'];
                  $HTTP_GET_VARS[op]="";
                  $_GET['op']="";
                  //include("special/".$events[$x]);
                  @(include("special/".$events[$x])) or redirect("forest.php"); this one 'cause sometimes I get en error calling special
                  $HTTP_GET_VARS[op]=$y;
                  $_GET['op'] = $yy;
With this correction you won't get anymore problems with your specials.

Have fun
Excalibur


Year, it is really a good idea.
But:
If you write a special like so:
Code:
if($_GET['op'] == "2")
{
 // Return to the Forest
}
elseif($_GET['op'] == "1")
{
 // Step 1
}
else
{
  // Beginnig
}

Or, better:

Code:
switch($_GET['op'])
{
  case "2":
    break;
  case "1":
    break;
  case "":
  case "search":
  default:
    break;
}

So nobody has anytime problems with $_GET and an special
(Year, you can use another key for a special, so $_GET['do'] or ['act'] or....)

But: Thanks to you
« Last Edit: February 17, 2006, 04:05:16 PM by Eliwood » Logged

Daenerys LotGD-Remake using PHP7 and a modern, headless approach.
Excalibur
Member
Mod God
*****
Offline Offline

Posts: 573


I'm a newbie, plz forgive me!


View Profile WWW
« Reply #2 on: February 17, 2006, 04:27:20 PM »

I don't see the problem you're trying to show me ...
until you stay "inside" you special event's code you can use any kind of operator, but when you go back to forest you restore the previous value of that variable (for any porpouse you might need).
In fact the first piece of code is the original written by Mighthy/Kendaer, and every special with $HTTP_GET_VARS['op'] worked smooth.
That code is necessary because you call a special with this link:
Quote
and usually special are something like this:
Code:
if ($_GET['op'] == "") {
   code
} else if ($_GET['op'] == "xxx") {
   code
} else if ($_GET['op'] == "yyy") {
   code
} else if ($_GET['op'] == "zzz") {
   code
} else if ($_GET['op'] == "kkk") {
   code
}
in this case if you don't set $_GET to null before including this special you'll get stuck with no nav, as your $_GET['op'] has been set to "search" by forest link.
when you'll exit by your special the forest code will restore the operator to "search" (or whatever is set to), and you'll continue on your way.

IF you call your special by another script (and not calling it from forest) you have no problem at all ... you can send the 'op' you need to, as you'll not execute the forest code.

I hope to be clear enough ... my english is rugged Wink
Logged

Spock: Random chance seems to have operated in our favor.
McCoy: In plain, non-Vulcan English, we've been lucky.
Spock: I believe I said that, Doctor.
Eliwood
Member
Codemeister
****
Offline Offline

Posts: 271


View Profile WWW
« Reply #3 on: February 17, 2006, 04:39:26 PM »

Please... Use "elseif" instead of "else if".
Its faster Wink

I don't show you any problems, i show you an another way, to made specials combatible to Servers which has these fix, and Servers whish hasn't it.

If the last case the begin, and if its "asked" with an else, so you never had any problem Smiley
And in a switch-Structur, default is the right way.

(PS: Your English is better than mine)
Logged

Daenerys LotGD-Remake using PHP7 and a modern, headless approach.
Pages: [1]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Welcome to DragonPrime - The LoGD Resource Community!

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Recent Topics
DragonPrime LoGD
Who's Online
12 Guests, 0 Users
Home Forums News Downloads Login Register Advanced Search