Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Ravens PHP Scripts And Web Hosting Forum Index -> Raven's RavenNuke(tm) v2.00.00 - v2.02.00 Distro
Author Message
bfnuke
Hangin' Around



Joined: Feb 01, 2006
Posts: 43

PostPosted: Mon Feb 06, 2006 9:16 am Reply with quote

Was looking through the code in Your_Account/index.php and came across this:

Code:


    if ($username != '') // SecurityReason.com Fix 2005 [sp3x]
    if((isset($cookie[1])) AND (strtolower($username) == strtolower($cookie[1])) AND ($userinfo['user_password'] == $cookie[2])) {
   echo "<font class=\"option\">".htmlentities($username).", "._WELCOMETO." $sitename!</font><br><br>";
   echo "<font class=\"content\">"._THISISYOURPAGE."</font></center><br><br>";
   /* Nav bar */
   nav(1);
   echo "<br><br>";
    } else {
   echo "<font class=\"title\">"._PERSONALINFO.": ".htmlentities($username)."</font></center><br><br>";
    }
   else Header("Location: modules.php?name=$module_name");


Notice specifically these 2 lines

Code:


    if ($username != '') // SecurityReason.com Fix 2005 [sp3x]
....
....
   else Header("Location: modules.php?name=$module_name");


Now maybe it is because I don't quite have a full handle on all the PHP tricks, but where are the { } for the if part? Or is the "if/else" clause considered a "single" line?

This is confusing the heck out of my editor that automatically finds the matching parts Wink
 
View user's profile Send private message
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Mon Feb 06, 2006 9:51 am Reply with quote

Laughing - it is a short-hand way of writing but it does get confusing with if/then/else logic. I don't write like that, but some do. They are sub-seting if's. Maybe this will help? Try changing the values of $x and $y to see the logic flow.

Code:
<?

$x=1;
$y=2;

if ($x==1)
    if ($y==2)
        echo "x is equal to 1 and y is equal to 2";
    else echo "x is equal to 1 but y is NOT equal to 2";
else echo "Neither x nor y are satisfied";
?>


It is best used when you only have if/then clauses, as in
Code:
<?

if ($x==1)
  if ($y==2)
    if ($z==3)
      echo "All if's are satisfied and I don't care if any parts aren't!";
?>
 
View user's profile Send private message
Display posts from previous:       
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Ravens PHP Scripts And Web Hosting Forum Index -> Raven's RavenNuke(tm) v2.00.00 - v2.02.00 Distro

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©