File: setup.php

package info (click to toggle)
icinga-web 1.7.1%2Bdfsg2-6
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 83,496 kB
  • sloc: php: 252,926; xml: 142,251; sql: 8,190; sh: 1,039; makefile: 575; perl: 215; python: 194
file content (72 lines) | stat: -rw-r--r-- 2,173 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/* The SQLite extension is enabled by default as of PHP 5.
 * Before that time the SQLite library is needed.
 *
 * For more info on setting up SQLite See:
 * http://www.php.net/manual/en/sqlite.installation.php
 *
 */
    if ($db = new SQLiteDatabase('imgorg.db')) {
        // Albums
//        $db->queryExec('DROP TABLE Albums');
        $db->queryExec('CREATE TABLE Albums (
            id INTEGER PRIMARY KEY,
            text STRING,
            created STRING,
            description TEXT
        );
        INSERT INTO Albums (text) VALUES ("Test");
        INSERT INTO Albums (text) VALUES ("Album2");');

        // Albums_Images
//        $db->queryExec('DROP TABLE Albums_Images');
        $db->queryExec('CREATE TABLE Albums_Images (
            album_id INTEGER,
            image_id INTEGER
        )');

        // Images_Tags
        $db->queryExec('CREATE TABLE Images_Tags (
            tag_id INTEGER,
            image_id INTEGER
        )');

        // Tags
//        $db->queryExec('DROP Table Tags');
        $db->queryExec('CREATE TABLE Tags (
            id INTEGER PRIMARY KEY,
            text STRING
        );
        INSERT INTO Tags (text) VALUES("Family");
        INSERT INTO Tags (text) VALUES("Friends");
        INSERT INTO Tags (text) VALUES("Other")');

        // Images
//        $db->queryExec('DROP TABLE Images');
        $db->queryExec('CREATE TABLE Images (
            id INTEGER PRIMARY KEY,
            filename STRING,
            url STRING,
            album_id INTEGER,
            description TEXT
        )');

//        $dir = "../../images/thumbs/";
//        $images = array();
//        $d = dir($dir);
//        $i = 0;
//        while($name = $d->read()){
//            if(!preg_match('/\.(jpg|gif|png)$/', $name)) continue;
//            $size = filesize($dir.$name);
//            $lastmod = filemtime($dir.$name)*1000;
//            $db->queryExec('INSERT INTO Images (filename, url) VALUES
//                ("'.$name.'","images/thumbs/'.$name.'")');
//        }
//        $d->close();


        echo json_encode($db->query('select * from Images')->fetchAll());
    } else {
        die($err);
    }