Advertisement
Guest User

Untitled

a guest
May 18th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.71 KB | None | 0 0
  1. <?php
  2. /////////////////////////////////////////////////////////////////////////////////////
  3. // xbtit - Bittorrent tracker/frontend
  4. //
  5. // Copyright (C) 2004 - 2007 Btiteam
  6. //
  7. // This file is part of xbtit.
  8. //
  9. // Redistribution and use in source and binary forms, with or without modification,
  10. // are permitted provided that the following conditions are met:
  11. //
  12. // 1. Redistributions of source code must retain the above copyright notice,
  13. // this list of conditions and the following disclaimer.
  14. // 2. Redistributions in binary form must reproduce the above copyright notice,
  15. // this list of conditions and the following disclaimer in the documentation
  16. // and/or other materials provided with the distribution.
  17. // 3. The name of the author may not be used to endorse or promote products
  18. // derived from this software without specific prior written permission.
  19. //
  20. // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
  21. // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  22. // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  23. // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
  25. // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  26. // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  27. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  28. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  29. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. //
  31. ////////////////////////////////////////////////////////////////////////////////////
  32.  
  33. if (!defined("IN_BTIT"))
  34. die("non direct access!");
  35.  
  36.  
  37. require_once(load_language("lang_login.php"));
  38.  
  39. function login() {
  40.  
  41. global $language, $logintpl;
  42.  
  43. $logintpl->set("language",$language);
  44. $language["INSERT_USERNAME"]=AddSlashes($language["INSERT_USERNAME"]);
  45. $language["INSERT_PASSWORD"]=AddSlashes($language["INSERT_PASSWORD"]);
  46.  
  47. $login=array();
  48. $login["action"]="index.php?page=login&returnto=".urlencode("index.php")."";
  49. $login["username"]=$user;
  50. $login["create"]="index.php?page=signup";
  51. $login["recover"]="index.php?page=recover";
  52. $logintpl->set("login",$login);
  53. }
  54.  
  55.  
  56. $logintpl=new bTemplate();
  57.  
  58.  
  59. if (!$CURUSER || $CURUSER["uid"]==1) {
  60.  
  61.  
  62. if (isset($_POST["uid"]) && $_POST["uid"])
  63. $user=$_POST["uid"];
  64. else $user='';
  65. if (isset($_POST["pwd"]) && $_POST["pwd"])
  66. $pwd=$_POST["pwd"];
  67. else $pwd='';
  68.  
  69. if (isset($_POST["uid"]) && isset($_POST["pwd"]))
  70. {
  71. if ($FORUMLINK=="smf")
  72. $smf_pass = sha1(strtolower($user) . $pwd);
  73. $res = do_sqlquery("SELECT u.id, u.random, u.password".(($FORUMLINK=="smf") ? ", u.smf_fid, s.passwd, s.passwordSalt" : "")." FROM {$TABLE_PREFIX}users u ".(($FORUMLINK=="smf") ? "LEFT JOIN {$db_prefix}members s ON u.smf_fid=s.ID_MEMBER" : "" )." WHERE u.username ='".AddSlashes($user)."'")
  74. or die(mysql_error());
  75. $row = mysql_fetch_array($res);
  76.  
  77. if (!$row)
  78. {
  79. $logintpl->set("FALSE_USER",true,true);
  80. $logintpl->set("FALSE_PASSWORD",false,true);
  81. $logintpl->set("login_username_incorrent",$language["ERR_USERNAME_INCORRECT"]);
  82. login();
  83. }
  84. elseif (md5($row["random"].$row["password"].$row["random"]) != md5($row["random"].md5($pwd).$row["random"]))
  85. {
  86. $logintpl->set("FALSE_USER",false,true);
  87. $logintpl->set("FALSE_PASSWORD",true,true);
  88. $logintpl->set("login_password_incorrent",$language["ERR_PASSWORD_INCORRECT"]);
  89. login();
  90. }
  91. else
  92. {
  93.  
  94. logincookie($row["id"],md5($row["random"].$row["password"].$row["random"]));
  95. if ($FORUMLINK=="smf" && $smf_pass==$row["passwd"])
  96. set_smf_cookie($row["smf_fid"], $row["passwd"], $row["passwordSalt"]);
  97. elseif ($FORUMLINK=="smf" && $row["password"]==$row["passwd"])
  98. {
  99. $salt=substr(md5(rand()), 0, 4);
  100. @mysql_query("UPDATE {$db_prefix}members SET passwd='$smf_pass', passwordSalt='$salt' WHERE ID_MEMBER=".$row["smf_fid"]);
  101. set_smf_cookie($row["smf_fid"], $smf_pass, $salt);
  102. }
  103. if (isset($_GET["returnto"]))
  104. $url=urldecode($_GET["returnto"]);
  105. else
  106. $url="index.php";
  107. redirect($url);
  108. die();
  109. }
  110. }
  111.  
  112. else
  113. {
  114. $logintpl->set("FALSE_USER",false,true);
  115. $logintpl->set("FALSE_PASSWORD",false,true);
  116. login();
  117. }
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124. }
  125. else {
  126.  
  127. if (isset($_GET["returnto"]))
  128. $url=urldecode($_GET["returnto"]);
  129. else
  130. $url="index.php";
  131. redirect($url);
  132. die();
  133. }
  134. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement