Advertisement
Guest User

Untitled

a guest
Aug 19th, 2016
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.60 KB | None | 0 0
  1. <?php
  2. // xampp code fix
  3. ini_set("display_errors", "0");
  4. $cf_register_moreip = true;
  5.  
  6. include_once "mysql.php";
  7. include_once "uuid.php";
  8. include_once "class/Utilities.php";
  9. include_once "config.php";
  10.  
  11. function get_money_player($connect, $id_playerpoint, $mysql)
  12. {
  13. $fetch = mysqli_fetch_array(
  14. mysqli_query($connect, "SELECT * FROM {$mysql['database_playerpoints']}.playerpoints WHERE id='{$id_playerpoint}'")
  15. );
  16.  
  17. if (mysqli_num_rows(mysqli_query($connect, "SELECT * FROM {$mysql['database_playerpoints']}.playerpoints WHERE id='{$id_playerpoint}'")) < 0)
  18. {
  19. echo "Không có tài khoản này!";
  20. return null;
  21. }
  22. return $fetch['points'];
  23. }
  24.  
  25. function get_id_playerpoint($connect, $auth_id, $mysql)
  26. {
  27. $s = get_uuid_from_authme($connect, $auth_id, $mysql);
  28.  
  29. $fetch = mysqli_fetch_array(
  30. mysqli_query($connect, "SELECT * FROM {$mysql['database_playerpoints']}.playerpoints WHERE playername='{$s}'")
  31. );
  32. return $fetch['id'];
  33. }
  34. function get_uuid_from_authme($connect, $id, $mysql)
  35. {
  36. $real_name = get_real_name_authme($connect, $id, $mysql);
  37. $uuid = uuidConvert($real_name);
  38. return $uuid;
  39. }
  40. function get_real_name_authme($connect, $id, $mysql)
  41. {
  42. $querys = mysqli_query($connect, "SELECT * FROM {$mysql["database_authme"]}.authme WHERE authme.id='{$id}'");
  43. $fetch = mysqli_fetch_array($querys);
  44. return $fetch['realname'];
  45. }
  46. function ping($ip, $port, $timeout)
  47. {
  48. $socket = fsockopen($ip, $port, $errno, $errstr, $timeout);
  49. if ($socket)
  50. {
  51. return true;
  52. } else {
  53. return false;
  54. }
  55. }
  56. function transfer($connect, $database_playerpoint, $transferer_id, $revicer_id, $amount)
  57. {
  58.  
  59. }
  60.  
  61. function changepassword($connect, $id, $oldPass, $newPass, $mysql)
  62. {
  63. $query1 = mysqli_fetch_array(mysqli_query($connect, "SELECT * FROM {$mysql["database_authme"]}.authme WHERE id='{$id}'"));
  64.  
  65. $oldpassword = $query1["password"];
  66.  
  67. if ($oldPass != $oldpassword)
  68. {
  69. alert("'Mật khẩu cũ bị sai! Hãy thử lại");
  70. exit();
  71. }
  72.  
  73. if (strlen($newPass) <= 6 && $newPass == md5("123456"))
  74. {
  75. alert("Mật khẩu của bạn phải lớn hơn 6 chữ số và không được là mật khẩu đơn giản như 123456, abcxyz,..");
  76. exit();
  77. }
  78.  
  79. $query2 = mysqli_query($connect, "UPDATE {$mysql["database_authme"]}.authme SET password='{$newPass}' WHERE id='{$id}'");
  80.  
  81. if ($query2)
  82. {
  83. alert("Thay đổi mật khẩu thành công! Mọi thứ trong server và trong trang web này sẽ đăng xuất ra!");
  84. navigation("../");
  85. session_destroy();
  86.  
  87. } else {
  88. echo"<script>alert('Đã có lỗi xảy ra trong lúc thay đổi mật khẩu!');</script>";
  89. }
  90. }
  91. function email_to_username($connect, $email, $mysql)
  92. {
  93. $query = mysqli_fetch_array(mysqli_query($connect, "SELECT * FROM {$mysql["database_authme"]}.authme WHERE email='{$email}'"));
  94. return $query['realname'];
  95. }
  96. function login($connect, $username, $password, $mysql)
  97. {
  98.  
  99. $query = mysqli_query($connect, "SELECT * FROM {$mysql["database_authme"]}.authme WHERE username='{$username}' OR realname='{$username}' OR email='{$username}'");
  100. $return_query = mysqli_fetch_array($query);
  101.  
  102. $money_user_id = get_id_playerpoint($connect, $return_query['id'], $mysql);
  103.  
  104. if (mysqli_num_rows($query) <= 0)
  105. {
  106. alert("Rất tiếc. Tài khoản này không tồn tại trong máy chủ.");
  107. navigation("../");
  108. exit();
  109. }
  110.  
  111. if ($return_query["password"] != $password)
  112. {
  113. alert("Mật khẩu của bạn không đúng. Hãy thử lại");
  114. navigation("../");
  115. exit;
  116. }
  117.  
  118. $_SESSION["user_id_authme"] = $return_query['id'];
  119. $_SESSION["user_id_playerpoint"] = $money_user_id;
  120. $_SESSION["user_login"] = true;
  121. alert("Đăng nhập thành công!");
  122. navigation("../");
  123.  
  124. }
  125. function login_popup($connect, $username, $password, $mysql)
  126. {
  127.  
  128. $query = mysqli_query($connect, "SELECT * FROM {$mysql["database_authme"]}.authme WHERE username='{$username}' OR realname='{$username}' OR email='{$username}'");
  129. $return_query = mysqli_fetch_array($query);
  130.  
  131. $money_user_id = get_id_playerpoint($connect, $return_query['id'], $mysql);
  132.  
  133. if (mysqli_num_rows($query) <= 0)
  134. {
  135. message("Rất tiếc. Tài khoản này không tồn tại trong máy chủ.");
  136. navigation("../");
  137. exit();
  138. }
  139.  
  140. if ($return_query["password"] != $password)
  141. {
  142. message("Mật khẩu của bạn không đúng. Hãy thử lại");
  143. navigation("../");
  144. exit;
  145. }
  146.  
  147. $_SESSION["user_id_authme"] = $return_query['id'];
  148. $_SESSION["user_id_playerpoint"] = $money_user_id;
  149. $_SESSION["user_login"] = true;
  150. message("Đăng nhập thành công!");
  151. navigation("../");
  152.  
  153. }
  154. function check_player($connect, $mysql, $authme_id)
  155. {
  156. $q = mysqli_query($connect, "SELECT * FROM {$mysql['database_authme']}.authme WHERE id='$authme_id'");
  157. if (mysqli_num_rows($q) <= 0)
  158.  
  159. return false;
  160. else return true;
  161. }
  162. function sendmail_recovery($connect, $mysql, $username, $default_url)
  163. {
  164. $username = strtolower($username);
  165. $realname = ucfirst($username);
  166.  
  167. $get_email_query = mysqli_query($connect, "SELECT * FROM {$mysql['database_authme']}.authme WHERE email='{$username}' OR username='{$username}' OR realname='{$realname}'");
  168.  
  169. $fetch = mysqli_fetch_array($get_email_query);
  170. if (mysqli_num_rows($get_email_query) <= 0)
  171. {
  172. echo '<script>alert("Dữ liệu của tài khoản này không tồn tại!");</script>';
  173. }
  174.  
  175. echo $fetch['password'];
  176.  
  177. // Always set content-type when sending HTML email
  178. $headers = "MIME-Version: 1.0" . "\r\n";
  179. $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
  180.  
  181. // More headers
  182. $headers .= 'Cc:'. $default_url . "\r\n";
  183.  
  184. // Thêm md5 (10*code)
  185. $codes_ = $default_url . "/forget.php?verify=".md5(10*$fetch['password']);
  186.  
  187. $body = "
  188. <body>
  189. Chào bạn. Nghe nói bạn quên mật khẩu đúng không =3=. Để được lấy lại mật khẩu :3 làm ơn nhấn vào link bên dưới nhé. Và nhớ giữ mật khẩu đừng quên nhé.<br>
  190. <b>---------</b>
  191. <br>
  192. Tài khoản: <b>{$username}</b>
  193. <br>
  194. <b>---------</b>
  195. Link lấy lại mật khẩu: <a href='{$default_url}'>{$default_url}</a>
  196. </body>
  197. ";
  198. mail($fetch['email'], "ss", $body, $headers);
  199. }
  200. function register($connect, $mysql, $realname, $password, $email)
  201. {
  202. $usernamedefault = addslashes(strtolower($realname));
  203. $real_name = addslashes($realname);
  204. $password = addslashes(md5($password));
  205. $ip = Utilities::get_client_ip();
  206. $email = addslashes($email);
  207.  
  208. if (mysqli_num_rows(mysqli_query($connect, "SELECT * FROM {$mysql['database_authme']}.authme WHERE ip='{$ip}'")) > 2)
  209. {
  210. message("IP của bạn đã hết lượt đăng ký! Nếu bạn đang chơi bằng net thì liên hệ ngay với admin để được mở thêm IP nhé");
  211. navigation("../dang-ky");
  212. exit;
  213. }
  214.  
  215. $query = mysqli_query($connect, "SELECT * FROM {$mysql['database_authme']}.authme WHERE username='{$usernamedefault}' OR realname='{$real_name}' OR email='{$email}'");
  216.  
  217. if ($query->num_rows > 0)
  218. {
  219. message("Tài khoản này đã có trên máy chủ. Hãy đăng nhập!");
  220. navigation("../dang-ky");
  221. exit;
  222. }
  223.  
  224.  
  225. $query1 = mysqli_query($connect, "INSERT INTO {$mysql['database_authme']}.authme (username, realname, password, ip, email)
  226. VALUES ('{$usernamedefault}', '{$real_name}', '{$password}', '{$ip}', '{$email}')");
  227. if ($query1)
  228. {
  229.  
  230. message("Đăng ký thành công. Hãy đăng nhập! Bạn có thể vào server bằng tài khoản này ngay bây giờ.");
  231. navigation("../dang-ky");
  232. exit;
  233. } else {
  234. alert("Đã có lỗi xảy ra trong lúc đăng ký. Hãy liên hệ admin");
  235. exit;
  236. }
  237. }
  238. function register_popup($connect, $mysql, $realname, $password, $email)
  239. {
  240. $usernamedefault = addslashes(strtolower($realname));
  241. $real_name = addslashes($realname);
  242. $password = addslashes(md5($password));
  243. $ip = Utilities::get_client_ip();
  244. $email = addslashes($email);
  245.  
  246. if (mysqli_num_rows(mysqli_query($connect, "SELECT * FROM {$mysql['database_authme']}.authme WHERE ip='{$ip}'")) > 2)
  247. {
  248. message("IP của bạn đã hết lượt đăng ký! Nếu bạn đang chơi bằng net thì liên hệ ngay với admin để được mở thêm IP nhé");
  249. exit;
  250. }
  251.  
  252. $query = mysqli_query($connect, "SELECT * FROM {$mysql['database_authme']}.authme WHERE username='{$usernamedefault}' OR realname='{$real_name}' OR email='{$email}'");
  253.  
  254. if ($query->num_rows > 0)
  255. {
  256. message("Tài khoản này đã có trên máy chủ. Hãy đăng nhập!");
  257. exit;
  258. }
  259.  
  260.  
  261. $query1 = mysqli_query($connect, "INSERT INTO {$mysql['database_authme']}.authme (username, realname, password, ip, email)
  262. VALUES ('{$usernamedefault}', '{$real_name}', '{$password}', '{$ip}', '{$email}')");
  263. if ($query1)
  264. {
  265.  
  266. message("Đăng ký thành công. Hãy đăng nhập! Bạn có thể vào server bằng tài khoản này ngay bây giờ.");
  267. navigation("../index");
  268. exit;
  269. } else {
  270. message("Đã có lỗi xảy ra trong lúc đăng ký. Hãy liên hệ admin");
  271. exit;
  272. }
  273. }
  274. function add_money( $connect, $mysql, $playerpoint_id, $amount )
  275. {
  276. $amount = intval($amount);
  277. $r = mysqli_query($connect, "UPDATE {$mysql['database_playerpoints']}.playerpoints SET points= points + {$amount} WHERE id='{$playerpoint_id}'");
  278. if ($r)
  279. {
  280. alert("Đã thêm " . $amount . " vào tài khoản.");
  281. } else {
  282. alert("Đã có lỗi xảy ra khi thêm tiền!");
  283. }
  284. }
  285.  
  286. function take_money( $connect, $mysql, $playerpoint_id, $amount )
  287. {
  288. $amount = intval($amount);
  289. $r = mysqli_query($connect, "UPDATE {$mysql}.playerpoints SET points= points - {$amount} WHERE id='{$playerpoint_id}'");
  290. if ($r)
  291. {
  292. alert("Đã lấy " . $amount . " từ tài khoản.");
  293. } else {
  294. alert("Đã có lỗi xảy ra khi lấy tiền!");
  295. }
  296. }
  297.  
  298. function message($msg)
  299. {
  300. echo "<script>alert('{$msg}');</script>";
  301. }
  302. function navigation($where)
  303. {
  304. echo "<script>location.href='".$where."'</script>";
  305. }
  306. function backtohistory()
  307. {
  308. echo "<script>
  309. for(i = 0;i <= 3;i++)
  310. {
  311. history.back();
  312. }
  313. </script>";
  314. }
  315. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement