You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.1 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <?php
  2. /* The SQLite extension is enabled by default as of PHP 5.
  3. * Before that time the SQLite library is needed.
  4. *
  5. * For more info on setting up SQLite See:
  6. * http://www.php.net/manual/en/sqlite.installation.php
  7. *
  8. */
  9. if ($db = new SQLiteDatabase('imgorg.db')) {
  10. // Albums
  11. // $db->queryExec('DROP TABLE Albums');
  12. $db->queryExec('CREATE TABLE Albums (
  13. id INTEGER PRIMARY KEY,
  14. text STRING,
  15. created STRING,
  16. description TEXT
  17. );
  18. INSERT INTO Albums (text) VALUES ("Test");
  19. INSERT INTO Albums (text) VALUES ("Album2");');
  20. // Albums_Images
  21. // $db->queryExec('DROP TABLE Albums_Images');
  22. $db->queryExec('CREATE TABLE Albums_Images (
  23. album_id INTEGER,
  24. image_id INTEGER
  25. )');
  26. // Images_Tags
  27. $db->queryExec('CREATE TABLE Images_Tags (
  28. tag_id INTEGER,
  29. image_id INTEGER
  30. )');
  31. // Tags
  32. // $db->queryExec('DROP Table Tags');
  33. $db->queryExec('CREATE TABLE Tags (
  34. id INTEGER PRIMARY KEY,
  35. text STRING
  36. );
  37. INSERT INTO Tags (text) VALUES("Family");
  38. INSERT INTO Tags (text) VALUES("Friends");
  39. INSERT INTO Tags (text) VALUES("Other")');
  40. // Images
  41. // $db->queryExec('DROP TABLE Images');
  42. $db->queryExec('CREATE TABLE Images (
  43. id INTEGER PRIMARY KEY,
  44. filename STRING,
  45. url STRING,
  46. album_id INTEGER,
  47. description TEXT
  48. )');
  49. // $dir = "../../images/thumbs/";
  50. // $images = array();
  51. // $d = dir($dir);
  52. // $i = 0;
  53. // while($name = $d->read()){
  54. // if(!preg_match('/\.(jpg|gif|png)$/', $name)) continue;
  55. // $size = filesize($dir.$name);
  56. // $lastmod = filemtime($dir.$name)*1000;
  57. // $db->queryExec('INSERT INTO Images (filename, url) VALUES
  58. // ("'.$name.'","images/thumbs/'.$name.'")');
  59. // }
  60. // $d->close();
  61. echo json_encode($db->query('select * from Images')->fetchAll());
  62. } else {
  63. die($err);
  64. }