summaryrefslogtreecommitdiff
path: root/doc/sample-insert-options.php
blob: 747a89415c6a47e2c48d26ba6c09d3fc4cb810a9 (plain)
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
#!/usr/bin/php
<?php
    if (isset($_SERVER["REQUEST_METHOD"]) || !empty($_SERVER["REQUEST_METHOD"])) {
        die("Not for execution through webserver");
    }

    require_once('lib/functions.php');

    $db = SQL::get_instance();

    $db->query("TRUNCATE TABLE `options`");

    exec("locale -a | cut -d'.' -f 1 | cut -d'@' -f1 | grep -E \"^([a-zA-Z_]*)\$\" | sort -u", $output);

//    var_dump($output);

    $json = json_encode($output);

//    var_dump($json);

    unset($output);

    $result = $db->query('INSERT INTO `options` (`attribute`, `option_values`) VALUES ('.
            '\'preferredlanguage\', \'' . $json . '\')');

    var_dump($result);
/*
    exec('cat ./iso3166-countrycodes.txt | sed -r -e \'s/(.*)\s+([A-Z]{2})\s+([A-Z]{3})\s+([0-9]{3})\s*$/\2/g\' -e \'/^[A-Z]{2}$/!d\'', $output);

    var_dump($output);

    sort($output);

    $json = json_encode($output);

//    var_dump($json);

    $result = $db->query('INSERT INTO `options` (`attribute`, `option_values`) VALUES ('.
            '\'c\', \'' . $json . '\')');

    var_dump($result);
*/
?>