Guest User

Untitled

a guest
Dec 8th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. function get_albums() {
  2.  
  3. $dbhost = "localhost";
  4. $dbuser = "root";
  5. $dbpassword = "";
  6. $dbdatabase = "visualupload";
  7.  
  8. $link = mysqli_connect($dbhost, $dbuser, $dbpassword, $dbdatabase);
  9.  
  10. $albums = array();
  11. $albums_query = "select 'albums.album_id','albums.timestamp','albums.name', LEFT('albums.description', 50) as 'description', COUNT('images.image_id') as 'image_count'
  12. FROM 'albums'
  13. LEFT JOIN 'images'
  14. ON 'albums.album_id' = 'images.album_id'
  15. WHERE 'albums.user_id' = " . $_SESSION['user_id'] . "
  16. GROUP BY 'albums.album_id'
  17. ";
  18.  
  19. $result = mysqli_query($link, $albums_query) or die(mysqli_error($link));
  20.  
  21. while ($albums_row = mysqli_fetch_assoc($result)) {
  22. $albums[] = array(
  23. 'id' => $albums_row['album_id'],
  24. 'timestamp' => $albums_row['timestamp'],
  25. 'name' => $albums_row['name'],
  26. 'description' => $albums_row['description'],
  27. 'count' => $albums_row['image_count']
  28. );
  29. }
  30.  
  31. return $albums;
  32. }
  33.  
  34. function create_album($album_name, $album_description) {
  35. $album_name = mysql_real_escape_string(htmlentities($album_name));
  36. $album_description = mysql_real_escape_string(htmlentities($album_description));
  37.  
  38. mysql_query("INSERT INTO 'albums' VALUES ('', '" . $_SESSION[user_id] . "', UNIX_TIMESTAMP()','$album_name','$album_description')");
  39. mkdir('uploads/' . mysql_insert_id(), 0744);
  40. mkdir('uploads/thumbs/' . mysql_insert_id(), 0744);
  41. }
Add Comment
Please, Sign In to add comment