home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 May / INTERNET103.ISO / pc / software / windows / building / php_nuke / html / modules / private_messages / auth.php next >
Encoding:
PHP Script  |  2002-09-16  |  3.5 KB  |  113 lines

  1. <?php
  2.  
  3. ######################################################################
  4. # PHP-NUKE: Advanced Content Management System
  5. # ============================================
  6. #
  7. # Copyright (c) 2002 by Francisco Burzi (fbc@mandrakesoft.com)
  8. # http://phpnuke.org
  9. #
  10. # Based on phpBB Forum
  11. # ====================
  12. # Copyright (c) 2001 by The phpBB Group
  13. # http://www.phpbb.com
  14. #
  15. # Integration based on PHPBB Forum Addon 1.4.0
  16. # ============================================
  17. # Copyright (c) 2001 by Richard Tirtadji
  18. # http://nukeaddon.com
  19. #
  20. # This program is free software. You can redistribute it and/or modify
  21. # it under the terms of the GNU General Public License as published by
  22. # the Free Software Foundation; either version 2 of the License.
  23. ######################################################################
  24.  
  25. if (eregi("auth.php",$PHP_SELF)) {
  26.     Header("Location: index.php");
  27.     die();
  28. }
  29.  
  30. require_once("mainfile.php");
  31. $module_name = basename(dirname(__FILE__));
  32. get_lang($module_name);
  33.  
  34. // Keledan begin
  35. // This lines should add user created before the forum upgrade to the table $prefix_user_status
  36.  
  37. if (is_user($user)) {
  38.     $user_data = base64_decode($user);
  39.     $userdata = explode(":", $user_data);
  40.     $sql = "SELECT * FROM ".$user_prefix."_users WHERE uid = ".$userdata[0]."";
  41.     $result = mysql_query($sql);
  42.     if (mysql_num_rows($result) < 1) {
  43.     $sql="INSERT into ".$user_prefix."_users (uid, user_posts, user_attachsig, user_rank, user_level) VALUES ('".$userid."',0,0,0,1)";
  44.         mysql_query($sql);
  45.     }
  46. }
  47.  
  48. // Keledan end
  49.  
  50. if(is_banned($REMOTE_ADDR, "ip", $db)) {
  51.     die(""._BBBANNED."");
  52. }
  53.  
  54. // set expire dates: one for a year, one for 10 minutes
  55.  
  56. $expiredate1 = time() + 3600 * 24 * 365;
  57. $expiredate2 = time() + 600;
  58.  
  59. // update LastVisit cookie. This cookie is updated each time auth.php runs
  60.  
  61. setcookie("LastVisit", time(), $expiredate1,  $cookiepath, $cookiedomain, $cookiesecure);
  62.  
  63. // set LastVisitTemp cookie, which only gets the time from the LastVisit
  64. // cookie if it does not exist yet
  65. // otherwise, it gets the time from the LastVisitTemp cookie
  66.  
  67. if (!isset($HTTP_COOKIE_VARS["LastVisitTemp"])) {
  68.     $temptime = $HTTP_COOKIE_VARS["LastVisit"];
  69. } else {
  70.     $temptime = $HTTP_COOKIE_VARS["LastVisitTemp"];
  71. }
  72.  
  73. // set cookie.
  74.  
  75. setcookie("LastVisitTemp", $temptime ,$expiredate2, $cookiepath, $cookiedomain, $cookiesecure);
  76.  
  77. // set vars for all scripts
  78.  
  79. $now_time = time();
  80. $last_visit = $temptime;
  81. $sql = "SELECT * FROM ".$prefix."_forum_config WHERE selected = 1";
  82. if($result = mysql_query($sql)) {
  83.     if($myrow = mysql_fetch_array($result)) {
  84.     $allow_html = $myrow["allow_html"];
  85.         $allow_bbcode = $myrow["allow_bbcode"];
  86.         $allow_sig = $myrow["allow_sig"];
  87.         $posts_per_page = $myrow["posts_per_page"];
  88.         $hot_threshold = $myrow["hot_threshold"];
  89.         $topics_per_page = $myrow["topics_per_page"];
  90.         $email_sig = stripslashes($myrow["email_sig"]);
  91.         $email_from = $myrow["email_from"];
  92.    }
  93. }
  94.  
  95. // We MUST do this up here, so it's set even if the cookie's not present.
  96.  
  97. $user_logged_in = 0;
  98. $logged_in = 0;
  99.  
  100. // Check for a cookie on the users's machine.
  101. // If the cookie exists, build an array of the users info and setup the theme.
  102. // new code for the session ID cookie..
  103.  
  104. if (is_user($user)) {
  105.     $user_logged_in = 1;
  106.     getusrinfo($user);
  107.     $userdata = get_userdata_from_id($userinfo[0], $db);
  108.     if (is_banned($userdata[user_id], "username", $db)) {
  109.     die(""._BBBANNED."");
  110.     }
  111. }
  112.  
  113. ?>