Tip: Click lines to highlight, hold ctrl/cmd to multi-select

http://codedumper.com/oqano (31-Dec @ 13:45)

Syntax Highlighted Code

  1.  
  2. //See what file is being requested by the web client, also store the arguments just in case.
  3. list($file,$arguments) = explode("?", $_SERVER['REQUEST_URI']);
  4.  
  5. //if the user just logged out, destroy this session and redirect them to root
  6. if("/wp-login.php?loggedout=true" == $file ."?" .$arguments)
  7. { session_destroy(); header("location: /"); }
  8.  
  9. //If our sentinel variable is set and true do nothing, allow normal script execution
  10. if(isset($_SESSION['valid_entrance']) && $_SESSION['valid_entrance'] == true) { /* As they say, "Silence is golden" */ }
  11.  
  12. //Now if the user is requesting wp-login.php and our sentinel is not true, redirect the "attacker" to root.
  13. elseif($file == "/wp-login.php" && !isset($_SESSION['valid_entrance']))
  14. {  header("Location: /"); exit(); }
  15.  
  16. //If the user is requesting the right login entrance set the sentinel to true
  17. elseif ($file == "/secure-login")
  18. {  $_SESSION['valid_entrance'] = true; }

Plain Code

 session_start();
 
//See what file is being requested by the web client, also store the arguments just in case.
list($file,$arguments) = explode("?", $_SERVER['REQUEST_URI']);
 
//if the user just logged out, destroy this session and redirect them to root
if("/wp-login.php?loggedout=true" == $file ."?" .$arguments)
{ session_destroy(); header("location: /"); }
 
//If our sentinel variable is set and true do nothing, allow normal script execution
if(isset($_SESSION['valid_entrance']) && $_SESSION['valid_entrance'] == true) { /* As they say, "Silence is golden" */ }
 
//Now if the user is requesting wp-login.php and our sentinel is not true, redirect the "attacker" to root.
elseif($file == "/wp-login.php" && !isset($_SESSION['valid_entrance']))
{  header("Location: /"); exit(); }
 
//If the user is requesting the right login entrance set the sentinel to true
elseif ($file == "/secure-login")
{  $_SESSION['valid_entrance'] = true; }

Permalink: http://codedumper.com/oqano