Guest User

Untitled

a guest
Nov 21st, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4.  
  5.  
  6.  
  7. $server = 'x.x.mysql';
  8. $dbuser = 'xxxxx';
  9. $dbpass = 'xxxxx';
  10. $dbname = 'xxxxx';
  11.  
  12. $connect = mysql_connect($server,$dbuser,$dbpass);
  13. mysql_select_db($dbname,$connect);
  14.  
  15.  
  16.  
  17.  
  18. $dirs = array_filter(glob('gbpics/*'), 'is_dir');
  19. foreach ($dirs as $dir) {
  20. $path = $dir . "/";
  21. $files = array_map('mysql_real_escape_string', array_filter(glob("{$path}*.*"), 'is_file'));
  22.  
  23. if (empty($files)) {
  24. echo "The data was inserted successfully.";
  25. } else {
  26. $insertValues = array();
  27. foreach ($files as $file) {
  28. $data = getimagesize($file);
  29. $width = $data[0];
  30. $height = $data[1];
  31. $insertValues[] = "('Titel', '{$dir}', '{$file}', '$width', '$height')";
  32. }
  33. $query = "INSERT INTO `gbpics` (`gbpictitel`, `gbpiccat`, `gbpicurl`, `gbpicwidth`, `gbpicheight`) VALUES " . implode(', ', $insertValues);
  34. if (!mysql_query($query)) {
  35. echo "There was a problem inserting the data.";
  36.  
  37. trigger_error("Query failed: $query<br />Error: " . mysql_error());
  38. } else {
  39. echo "The data was inserted successfully.";
  40. }
  41. }
  42. }
  43. ?>
Add Comment
Please, Sign In to add comment