Advertisement
Guest User

Untitled

a guest
Jul 5th, 2017
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. <?php
  2. $html = file_get_contents("guestbook.html");
  3. $username="usr_10746419";
  4. $password="746419";
  5. $database="db_10746419";
  6. $db = mysql_connect("atlas.dsv.su.se", $username,$password)
  7. or die("Unable to connect to sql server");
  8.  
  9. mysql_select_db($database,$db) or die("Unable to select database");
  10.  
  11. if(isset($_POST['submit'])){
  12. $comment =mysql_real_escape_string( htmlentities($_POST['comment']));
  13. $homepage = mysql_real_escape_string( htmlentities($_POST['homepage']));
  14. $name = mysql_real_escape_string( htmlentities($_POST['name']));
  15. $email = mysql_real_escape_string( htmlentities($_POST['email']));
  16.  
  17. $form_data = $_FILES['file']['tmp_name'];
  18. $data_type = $_FILES['file']['filetype'];
  19. if ($_FILES['file']['name'] == "" || $_FILES['file']['error'] > 0) echo "phail";
  20. $file = fopen($form_data, "rb");
  21. $data = addslashes(fread($file, filesize($form_data)));
  22. fclose($file);
  23. @mysql_query("BEGIN");
  24.  
  25. $query1 = "INSERT INTO picture (bin_data,filetype) ".
  26. "VALUES ('$data','$data_type')";
  27.  
  28. mysql_query($query1,$db) or die ("insert bild funkade inte");
  29. $id = mysql_insert_id();
  30. $query2 = "INSERT INTO guestbook (pid,email, comment, name, surname, homepage)
  31. VALUES ('$id','$email','$comment','$name','default','$homepage')";
  32.  
  33. mysql_query($query2,$db) or die("kek");
  34.  
  35. @mysql_query("COMMIT");
  36.  
  37. header("Location: ".$_SERVER['PHP_SELF']);
  38. }
  39. $query = "SELECT * FROM guestbook, picture WHERE picture.id = pid";
  40.  
  41. eval("print \"" . addcslashes(preg_replace("/(---(.+?)---)/", "\\2", $html), '"') . "\";");
  42.  
  43. if ($results = mysql_query($query, $db)) {
  44. while ($row = mysql_fetch_assoc($results)) {
  45. $name=$row['name'];
  46. $comment=$row['comment'];
  47. $email=$row['email'];
  48. $date=$row['date'];
  49. $id=$row['id'];
  50. $pid = $row['pid'];
  51. header("Content-Type: ".$row['filetype']);
  52.  
  53. $image = ($pid == NULL) ? "" : "<img src=\"guestbook.php?pid=$pid\" />";
  54.  
  55. echo "<b>Inlägg ".$id." </b> <br /> <br />";
  56. echo "<b>Tid: </b> ".$date."<br />";
  57. echo "<b>Från:</b> ".$name." <br />";
  58. echo "<b>E-post: </b> ".$email." <br /> <br />";
  59. echo "<b>Kommentar:</b> ".$comment."<br /> <br /> ";
  60. echo $row['bin_data'];
  61. }
  62. }
  63. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement