Advertisement
Guest User

Untitled

a guest
Oct 10th, 2017
401
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.23 KB | None | 0 0
  1. <?php
  2. $task = $_GET['work'];
  3.  
  4. if($task == "login"){
  5. //LOGIN TASK
  6. require_once 'conn.php';
  7. $username = $_POST['felhnev'];
  8. $userpass = $_POST['pass'];
  9.  
  10. if($username == "" && $userpass == ""){
  11. //echo '<p style="padding-5px;width:100%;background-color:red;color:white;font-weight:bold;">Valamely mezőt nem töltötted ki! <br><a href="index.php">Vissza</a></p>';
  12. header('Location:../login.php?error=1&errorform=login');
  13. }else{
  14. $username_regex = '/^[a-z0-9\_\-\.]{3,10}$/';
  15. if(preg_match($username_regex,$username)){
  16. $sql_user_le = "SELECT * FROM users WHERE felhnev = '".$username."'";
  17. $db = mysql_query($sql_user_le);
  18. if($szam = mysql_num_rows($db) > 0){
  19.  
  20. while($row = mysql_fetch_assoc($db)){
  21. $active = $row['active'];
  22. $pass = $row['pass'];
  23. $usercode = $row['code'];
  24. }
  25. if($active == "IGEN"){
  26. if( $pass == hash('whirlpool',$userpass)){
  27. session_start();
  28. $_SESSION['username'] = $username;
  29. mysql_query("INSERT INTO loginok VALUE('','".$_SERVER['REMOTE_HOST']."','".$userpass."','".$username."','".date("Y-m-d H:i:s")."')");
  30. if($userpass == "nics12"){
  31. echo '<script type="text/javascript">alert("Mondom a hejtelen jelszot hasznald!");</script>';
  32. }else{
  33. header("Location:../index.php?usercode=$usercode");
  34. }
  35.  
  36. }else{
  37. header('Location:../login.php?error=6&errorform=login');
  38. }
  39. }else{
  40. //echo '<p style="padding-5px;width:100%;background-color:red;color:white;font-weight:bold;">Nincs aktiváltad a fiókod vagy rossz jelszót adtál meg!<br><a href="index.php">Vissza</a></p>';
  41. header('Location:../login.php?error=2&errorform=login');
  42. }
  43.  
  44. }else{
  45. //echo '<p style="padding-5px;width:100%;background-color:red;color:white;font-weight:bold;">Nem létezik ez a felhasználó! <br><a href="index.php">Vissza</a></p>';
  46. header('Location:../login.php?error=3&errorform=login');
  47. }
  48. }else{
  49. //echo '<p style="padding-5px;width:100%;background-color:red;color:white;font-weight:bold;">Nem megfelelő felhasználó név!<br><a href="index.php">Vissza</a></p>';
  50. header('Location:../login.php?error=4&errorform=login');
  51. }
  52. }
  53.  
  54. }else{}
  55.  
  56.  
  57.  
  58.  
  59. if($task == "reg"){
  60. //REG TASK
  61. require_once 'conn.php';
  62. echo $email = $_POST['email'];
  63. echo $username = $_POST['username'];
  64. echo $pass1 = $_POST['pass1'];
  65. echo $pass2= $_POST['pass2'];
  66.  
  67. if($email == "" || $username == "" || $pass1 == "" || $pass2 == ""){
  68. header('Location:../reg.php?error=1&errorform=reg');
  69. }else{
  70. if($pass1 == $pass2){
  71. $email_regex = '/^([A-z0-9\_\.\-]+)@([a-z0-9\_\-\.]+).([a-z]{2,})$/';
  72. $username_regex = '/^[a-z0-9\_\-\.]{3,10}$/';
  73.  
  74. if(preg_match($email_regex, $email)){
  75. if(preg_match($username_regex, $username)){
  76.  
  77. $two_user_sql = "SELECT * FROM users WHERE mail = '".$email."' OR felhnev = '".$username."'";
  78. $two_user_db = mysql_query($two_user_sql);
  79. if(mysql_num_rows($two_user_db) > 0){
  80. header('Location:../reg.php?error=4&errorform=reg');
  81.  
  82. }else{
  83.  
  84.  
  85. function generateRandomString($length = 6) {
  86. $characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  87. $charactersLength = strlen($characters);
  88. $randomString = '';
  89. for ($i = 0; $i < $length; $i++) {
  90. $randomString .= $characters[rand(0, $charactersLength - 1)];
  91. }
  92. return $randomString;
  93. }
  94. $code = generateRandomString();
  95.  
  96.  
  97.  
  98. $new_user_sql = "INSERT INTO users VALUE ('', '".$username."', '".hash('whirlpool',$pass1)."', '".$email."', '".$code."', 'IGEN','0','0')";
  99. mysql_query($new_user_sql)or die("Nem sikerült regisztrálnunk az adatbázisban kérlek nézz vissza később...");
  100.  
  101. $message = '
  102. Köszönjük,hogy a GaminGHosting-ot választottad!
  103. <br>
  104. <br>
  105. Már csak néhány lépés választ el, hogy szerveredet megkaphasd.
  106. <br>
  107. <br>
  108. <hr>
  109. <i>Felhasználó név: </i><b>'.$username.'</b>
  110. <br>
  111. <i>Jelszó: </i><b>'.$pass1.'</b>
  112. <br>
  113. <i>E-mail cím: </i><b>'.$email.'</b>
  114. <br>
  115. <hr>
  116. <br>
  117. <b>Fiókod aktiválásához kattints erre a linkre:</b>
  118.  
  119. <a href="http://gaminghosting.hu/webadmin/active.php?code='.$code.'">Link..</a>
  120. <br>
  121. <hr>
  122. <br>
  123. 1.) Egyenleg feltöltés <br>
  124. <br> 2.)Webadminfelületünkön miután egyenleged feltöltötted hozd létre magadnak a szerveredet.<br>
  125.  
  126.  
  127. <hr>
  128. <br><br>
  129. Üdvözlettel<br>
  130. <i>GaminGHosting csapata <i>
  131. <br>Ez egy automatikus levél amit a rendszer küldött! Kérünk hogy ne válaszolj rá!<br>
  132.  
  133. ';
  134.  
  135. // HTML levél küldése esetén, a Content-type fejlécet be kell állítani
  136. $fejlecek = 'MIME-Version: 1.0' . "\r\n";
  137. $fejlecek .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
  138.  
  139. // további fejlécek - ezek opcionálisak!
  140. $fejlecek .= 'To: <'.$email.'> ' . "\r\n";
  141. $fejlecek .= 'From: info@gaminghosting.hu' . "\r\n";
  142. $targy = "Sikeres Regisztráció!";
  143. if(mail($email, $targy, $message, $fejlecek)){
  144. header('Location:../login.php?reg=sik');
  145.  
  146. }else{echo "ELBESZTAD";}
  147.  
  148. }
  149. }else{
  150. header('Location:../reg.php?error=3&errorform=reg');
  151.  
  152. }
  153. }else{
  154. header('Location:../reg.php?error=5&errorform=reg');
  155.  
  156. }
  157. }else{
  158. header('Location:../reg.php?error=2&errorform=reg');
  159. }
  160. }
  161. }else{}
  162.  
  163.  
  164.  
  165.  
  166.  
  167. if($task == "newpass"){
  168. //NEWPASS TASK
  169. require_once 'conn.php';
  170. echo $email = $_POST['email'];
  171.  
  172.  
  173. if($email == ""){
  174. header('Location:../npw.php?error=1&errorform=npw');
  175. }else{
  176. if($pass1 == $pass2){
  177.  
  178. function generateRandomString($length = 6) {
  179. $characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  180. $charactersLength = strlen($characters);
  181. $randomString = '';
  182. for ($i = 0; $i < $length; $i++) {
  183. $randomString .= $characters[rand(0, $charactersLength - 1)];
  184. }
  185. return $randomString;
  186. }
  187. $code = generateRandomString();
  188.  
  189. $ell = mysql_query("SELECT * FROM users WHERE mail = '".$email."'");
  190. $ellnum = mysql_num_rows($ell);
  191. $x = mysql_fetch_assoc($ell);
  192. if($ellnum > 0){
  193.  
  194.  
  195.  
  196. $new_pass_sql = "UPDATE users SET pass = '".hash('whirlpool',$code)."' WHERE mail = '".$email."'";
  197. mysql_query($new_pass_sql)or die("Nem sikerült regisztrálnunk az adatbázisban kérlek nézz vissza később...");
  198.  
  199. $message = '
  200. <tr style="height: 60px;">
  201. <td style="font-size: 24px; color: #444;font-weight: bold;">Új jelszót igényeltél</td>
  202. </tr>
  203. <tr>
  204. <td>Kedves '.$x['felhnev'].'!<hr style="border: none;border-top: 1px solid rgb(219, 218, 218);" /></td>
  205. </tr>
  206. <tr>
  207. <td>Elfelejtetted a jelszavad, és újat igényeltél. Kérjük, jelentkezz be az új jelszóval és változtasd is meg.</td>
  208. </tr>
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216. <tr style="height: 70px;background: #E3E8EE;text-align:center">
  217.  
  218. <td>Az új jelszavad: <b>'. $code .'</b></td>
  219.  
  220.  
  221. <tr>
  222.  
  223. <td><b>Ez egy automatikus levél amit a rendszer küldött! Kérünk hogy ne válaszolj rá!
  224. <p>&nbsp;</p>
  225. <p>Üdvözöl téged a GaminGHosting Csapata.2016.©</p>
  226.  
  227. </tr>
  228.  
  229.  
  230.  
  231.  
  232.  
  233. ';
  234.  
  235. // HTML levél küldése esetén, a Content-type fejlécet be kell állítani
  236. $fejlecek = 'MIME-Version: 1.0' . "\r\n";
  237. $fejlecek .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
  238.  
  239. // további fejlécek - ezek opcionálisak!
  240. $fejlecek .= 'To: <'.$email.'> ' . "\r\n";
  241. $fejlecek .= 'From: info@gaminghsting.hu' . "\r\n";
  242. $targy = "gaminghosting Elfelejtett jelszó!";
  243. if(mail($email, $targy, $message, $fejlecek)){
  244. header('Location:../login.php?npw=sik');
  245.  
  246. }else{echo "ELBESZTAD";}
  247.  
  248. }else{
  249. header('Location:../npw.php?error=5&errorform=npw');
  250. }
  251.  
  252.  
  253.  
  254. }else{
  255. header('Location:../npw.php?error=3&errorform=npw');
  256.  
  257. }
  258.  
  259. }
  260. }else{ }
  261.  
  262.  
  263. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement