Guest User

Untitled

a guest
May 9th, 2012
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. <?php
  2. if($_SERVER['SCRIPT_FILENAME'] == str_replace('\\', '/', __FILE__)) {
  3. // You cannot request this file directly.
  4. header('Location: ../', true, 302);
  5. exit;
  6. }
  7.  
  8. // 'false' means that the user is not logged in as a moderator
  9. $mod = false;
  10.  
  11. // Set the session name.
  12. session_name($config['cookies']['session']);
  13.  
  14. // Set session parameters
  15. session_set_cookie_params(0, $config['cookies']['jail']?$config['root']:'/');
  16.  
  17. // Start the session
  18. session_start();
  19.  
  20. // Session creation time
  21. if(!isset($_SESSION['created'])) $_SESSION['created'] = time();
  22.  
  23. if(!isset($_COOKIE[$config['cookies']['hash']]) || !isset($_COOKIE[$config['cookies']['time']]) || $_COOKIE[$config['cookies']['hash']] != md5($_COOKIE[$config['cookies']['time']] . $config['cookies']['salt'])) {
  24. $time = time();
  25. setcookie($config['cookies']['time'], $time, time()+$config['cookies']['expire'], $config['cookies']['jail']?$config['cookies']['path']:'/', null, false, true);
  26. setcookie($config['cookies']['hash'], md5($time . $config['cookies']['salt']), $time+$config['cookies']['expire'], $config['cookies']['jail']?$config['cookies']['path']:'/', null, false, true);
  27. $user = Array('valid' => false, 'appeared' => $time);
  28. } else {
  29. $user = Array('valid' => true, 'appeared' => $_COOKIE[$config['cookies']['time']]);
  30. }
  31.  
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment