Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1. <?php
  2. $avatar;
  3. if ($_POST['name'] != null){
  4. $userName = $_POST['name'];
  5. }
  6. if ($_POST['city'] != null ) {
  7. $userCity = $_POST['city'];
  8. }
  9. if ($_POST['desc'] != null){
  10. $userDesc = $_POST['desc'];
  11. }
  12.  
  13. if ($_POST['login'] != null || $_POST['pass'] != null || $_POST['mail'] != null) {
  14. $userLogin = $_POST['login'];
  15. $userPass = $_POST['pass'];
  16. $userMail = $_POST['mail'];
  17. $len = 20;
  18. $userID = substr(sha1(rand(1,10000)),0,$len);
  19. echo $userID;
  20. if(!empty($_FILES)){
  21. $avatar = fileReceive();
  22.  
  23. }
  24. reg();
  25.  
  26. }
  27. else
  28. {
  29. header("Location: ../reg.php?reg=emptyf");
  30. }
  31. function reg(){
  32. global $userID, $userMail, $userPass, $userLogin, $userDesc, $userCity, $userName, $avatar;
  33. try {
  34. $host = 'localhost';
  35. $baza = 'user';
  36. $uzytkownik = 'adamek';
  37. $haslo = 'aaaaa5';
  38.  
  39.  
  40. $conn = new PDO("mysql:host=$host;dbname=$baza", $uzytkownik, $haslo);
  41. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  42. #$stmt = $conn->prepare("SELECT Nazwa FROM Users WHERE Nazwa = '$userLogin'");
  43. #$stmt->execute();
  44. #$row = $stmt->fetch();
  45. #if($row[0] <> 1){
  46. #$stmt = $conn->prepare("INSERT INTO 'Users' ('ID', 'Nazwa','Haslo', 'mail','name','city', 'image', 'desc', 'activate', 'admin') VALUES ('$userID','$userLogin', '$userPass', '$userMail', '$userName', '$userCity, $avatar', '$userDesc','false','false'");
  47. #$stmt->execute();
  48.  
  49. #$sendMail();
  50.  
  51. }
  52.  
  53. #$else{
  54. # header("Location: ../reg.php?reg=userexists");
  55. #}
  56. #}
  57. catch(PDOException $e)
  58. {
  59. echo "duppppp";
  60. }
  61. }
  62.  
  63.  
  64.  
  65.  
  66. function fileReceive(){
  67. $max_size = 1024*1024;
  68. if (is_uploaded_file($_FILES['filename']['tmp_name'])) {
  69. if ($_FILES['filename']['size'] > $max_size) {
  70. echo 'Błąd! Plik jest za duży!';
  71. }
  72. else {
  73. echo 'Odebrano plik. Początkowa nazwa: '.$_FILES['filename']['name'];
  74. echo '<br/>';
  75. if (isset($_FILES['filename']['type'])) {
  76. echo 'Typ: '.$_FILES['filename']['type'].'<br/>';
  77. }
  78. $strExt = substr( $_FILES['filename']['name'], strrpos( $_FILES['filename']['name'], '.' ) + 1 );
  79. echo "Rozszerzenie: ". $strExt;
  80. $len = 20;
  81. $randstring = substr(sha1(rand(1,10000)),0,$len).".jpg";
  82. echo $randstring;
  83. echo $_FILES['filename']['name'];
  84.  
  85. if ($strExt == 'jpg' || 'JPG' || 'jpeg' || 'JPEG'){
  86. move_uploaded_file($_FILES['filename']['tmp_name'],
  87. $_SERVER['DOCUMENT_ROOT'].'../avatars/'.$_FILES['filename']['name']);
  88.  
  89. }
  90. else{
  91. echo "niy!!";}
  92. }
  93. } else {
  94. echo 'Błąd przy przesyłaniu danych!';
  95. }
  96.  
  97. rename('../avatars/'.$_FILES['filename']['name'], 'avatars/'.$randstring);
  98. }
  99.  
  100.  
  101.  
  102. function sendMail(){
  103. ob_start();
  104. $addressee = 'ajjambor912@gmail.com';
  105. @$email = $_POST['email'];
  106.  
  107. @$content = 'Name '.$_POST['username'].' Phone: '.$_POST['userphone'].' Content: '.$_POST['message'];
  108.  
  109. $header = "From: ".$_POST['email']." \nContent-Type:".
  110. ' text/plain;charset="iso-8859-2"'.
  111. "\nContent-Transfer-Encoding: 8bit";
  112. if (mail($addressee, 'Message from NAhandyman: ', $content , $header))
  113.  
  114. header('Location:index.php?send=true');
  115. else
  116. header('Location:index.php?send=false');
  117. }
  118. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement