3 require_once __DIR__
. '/../vendor/autoload.php';
5 use Symfony\Component\Yaml\Yaml
;
7 $parameters = Yaml
::parse(file_get_contents('app/config/parameters.yml'));
9 echo 'Okay, you want to install wallabag, let\'s go!';
12 function executeQuery($handle, $sql, $params) {
15 $query = $handle->prepare($sql);
16 $query->execute($params);
17 return $query->fetchAll();
25 $configFile = 'app/config/config.inc.php';
26 $dbFile = 'data/db/poche.sqlite';
27 $username = 'wallabag';
28 $password = 'wallabag';
29 $salt = $parameters['parameters']['secret'];
30 $defaultLanguage = 'en_EN.UTF8';
32 if (!copy('app/config/config.inc.default.php', $configFile)) {
33 die('Installation aborted, impossible to create ' . $configFile . ' file. Maybe you don\'t have write access to create it.');
36 $content = file_get_contents($configFile);
37 $content = str_replace("define ('SALT', '');", "define ('SALT', '".$salt."');", $content);
38 file_put_contents($configFile, $content);
40 if (!copy('bin/poche.sqlite', $dbFile)) {
41 die('Impossible to create ' . $dbFile . ' file.');
46 $dbPath = 'sqlite:' . realpath('') . '/' . $dbFile;
48 $handle = new PDO($dbPath);
50 $handle->setAttribute(PDO
::ATTR_ERRMODE
, PDO
::ERRMODE_EXCEPTION
);
52 $saltedPassword = sha1($password . $username . $salt);
54 $sql = "INSERT INTO users (username, password, name, email) VALUES (?, ?, ?, '')";
55 $params = array($username, $saltedPassword, $username);
56 $query = executeQuery($handle, $sql, $params);
58 $idUser = (int)$handle->lastInsertId('users_id_seq');
60 $sql = 'INSERT INTO users_config ( user_id, name, value ) VALUES (?, ?, ?)';
61 $params = array($idUser, 'pager', '10');
62 $query = executeQuery($handle, $sql, $params);
64 $sql = 'INSERT INTO users_config ( user_id, name, value ) VALUES (?, ?, ?)';
65 $params = array($idUser, 'language', $defaultLanguage);
66 $query = executeQuery($handle, $sql, $params);
68 echo 'wallabag is now installed';
70 echo 'Just execute `php app/console server:run` for using wallabag:';
72 echo 'http://localhost:8000';