3 * wallabag, self hostable application allowing you to not miss any content anymore
6 * @author Nicolas LÅ“uillet <nicolas@loeuillet.org>
8 * @license http://opensource.org/licenses/MIT see COPYING file
14 /* Function taken from at http://php.net/manual/en/function.rmdir.php#110489
15 * Idea : nbari at dalmp dot com
17 * Here in case of .gitignore files
19 function delTree($dir) {
20 $files = array_diff(scandir($dir), array('.','..'));
21 foreach ($files as $file) {
22 (is_dir("$dir/$file")) ? delTree("$dir/$file") : unlink("$dir/$file");
27 if (isset($_GET['clean'])) {
28 if (is_dir('install')){
30 header('Location: index.php');
34 if (isset($_POST['download'])) {
35 if (!file_put_contents("cache
/vendor
.zip
", fopen("http
://static.wallabag.org/files/vendor.zip", 'r'))) {
36 $errors[] = 'Impossible to download vendor.zip. Please <a href="http://wllbg.org/vendor">download it manually</a> and unzip it in your wallabag folder.';
39 if (extension_loaded('zip')) {
40 $zip = new ZipArchive();
41 if ($zip->open("cache/vendor.zip") !== TRUE){
42 $errors[] = 'Impossible to open cache/vendor.zip. Please unzip it manually in your wallabag folder.';
44 if ($zip->extractTo(realpath(''))) {
45 @unlink("cache/vendor.zip");
46 $successes[] = 'twig is now installed, you can install wallabag.';
49 $errors[] = 'Impossible to extract cache/vendor.zip. Please unzip it manually in your wallabag folder.';
54 $errors[] = 'zip extension is not enabled in your PHP configuration. Please unzip cache/vendor.zip in your wallabag folder.';
58 else if (isset($_POST['install'])) {
59 if (!is_dir('vendor')) {
60 $errors[] = 'You must install twig before.';
64 // Create config.inc.php
65 if (!copy('inc/poche/config.inc.default.php', 'inc/poche/config.inc.php')) {
66 $errors[] = 'Installation aborted, impossible to create inc/poche/config.inc.php file. Maybe you don\'t have write access to create it.';
70 function generate_salt() {
71 mt_srand(microtime(true)*100000 +
memory_get_usage(true));
72 return md5(uniqid(mt_rand(), true));
75 $content = file_get_contents('inc/poche/config.inc.php');
76 $salt = generate_salt();
77 $content = str_replace("define ('SALT', '');", "define ('SALT', '".$salt."');", $content);
78 file_put_contents('inc/poche/config.inc.php', $content);
84 $username = trim($_POST['username']);
85 $password = trim($_POST['password']);
86 $salted_password = sha1($password . $username . $salt);
88 // Database informations
89 if ($_POST['db_engine'] == 'sqlite') {
90 if (!copy('install/poche.sqlite', 'db/poche.sqlite')) {
91 $errors[] = 'Impossible to create inc/poche/config.inc.php file.';
95 $db_path = 'sqlite:' . realpath('') . '/db/poche.sqlite';
96 $handle = new PDO($db_path);
101 $content = file_get_contents('inc/poche/config.inc.php');
103 if ($_POST['db_engine'] == 'mysql') {
104 $db_path = 'mysql:host=' . $_POST['mysql_server'] . ';dbname=' . $_POST['mysql_database'];
105 $content = str_replace("define ('STORAGE_SERVER', 'localhost');", "define ('STORAGE_SERVER', '".$_POST['mysql_server']."');", $content);
106 $content = str_replace("define ('STORAGE_DB', 'poche');", "define ('STORAGE_DB', '".$_POST['mysql_database']."');", $content);
107 $content = str_replace("define ('STORAGE_USER', 'poche');", "define ('STORAGE_USER', '".$_POST['mysql_user']."');", $content);
108 $content = str_replace("define ('STORAGE_PASSWORD', 'poche');", "define ('STORAGE_PASSWORD', '".$_POST['mysql_password']."');", $content);
109 $handle = new PDO($db_path, $_POST['mysql_user'], $_POST['mysql_password']);
111 $sql_structure = file_get_contents('install/mysql.sql');
113 else if ($_POST['db_engine'] == 'postgres') {
114 $db_path = 'pgsql:host=' . $_POST['pg_server'] . ';dbname=' . $_POST['pg_database'];
115 $content = str_replace("define ('STORAGE_SERVER', 'localhost');", "define ('STORAGE_SERVER', '".$_POST['pg_server']."');", $content);
116 $content = str_replace("define ('STORAGE_DB', 'poche');", "define ('STORAGE_DB', '".$_POST['pg_database']."');", $content);
117 $content = str_replace("define ('STORAGE_USER', 'poche');", "define ('STORAGE_USER', '".$_POST['pg_user']."');", $content);
118 $content = str_replace("define ('STORAGE_PASSWORD', 'poche');", "define ('STORAGE_PASSWORD', '".$_POST['pg_password']."');", $content);
119 $handle = new PDO($db_path, $_POST['pg_user'], $_POST['pg_password']);
121 $sql_structure = file_get_contents('install/postgres.sql');
124 $content = str_replace("define ('STORAGE', 'sqlite');", "define ('STORAGE', '".$_POST['db_engine']."');", $content);
125 file_put_contents('inc/poche/config.inc.php', $content);
130 function executeQuery($handle, $sql, $params) {
133 $query = $handle->prepare($sql);
134 $query->execute($params);
135 return $query->fetchAll();
143 // create database structure
144 $query = executeQuery($handle, $sql_structure, array());
147 $handle->setAttribute(PDO
::ATTR_ERRMODE
, PDO
::ERRMODE_EXCEPTION
);
149 $sql = 'INSERT INTO users (username, password, name) VALUES (?, ?, ?)';
150 $params = array($username, $salted_password, $username);
151 $query = executeQuery($handle, $sql, $params);
153 $id_user = $handle->lastInsertId();
155 $sql = 'INSERT INTO users_config ( user_id, name, value ) VALUES (?, ?, ?)';
156 $params = array($id_user, 'pager', '10');
157 $query = executeQuery($handle, $sql, $params);
159 $sql = 'INSERT INTO users_config ( user_id, name, value ) VALUES (?, ?, ?)';
160 $params = array($id_user, 'language', 'en_EN.UTF8');
161 $query = executeQuery($handle, $sql, $params);
163 $successes[] = 'wallabag is now installed. You can now <a href="index.php?clean=0">access it !</a>';
172 <meta name
="viewport" content
="initial-scale=1.0">
173 <meta charset
="utf-8">
175 <meta http
-equiv
="X-UA-Compatible" content
="IE=10">
177 <title
>wallabag
- installation
</title
>
178 <link rel
="shortcut icon" type
="image/x-icon" href
="themes/baggy/img/favicon.ico" />
179 <link rel
="apple-touch-icon-precomposed" sizes
="144x144" href
="themes/baggy/img/apple-touch-icon-144x144-precomposed.png">
180 <link rel
="apple-touch-icon-precomposed" sizes
="72x72" href
="themes/baggy/img/apple-touch-icon-72x72-precomposed.png">
181 <link rel
="apple-touch-icon-precomposed" href
="themes/baggy/img/apple-touch-icon-precomposed.png">
182 <link href
='//fonts.googleapis.com/css?family=PT+Sans:700' rel
='stylesheet' type
='text/css'>
183 <link rel
="stylesheet" href
="themes/baggy/css/ratatouille.css" media
="all">
184 <link rel
="stylesheet" href
="themes/baggy/css/font.css" media
="all">
185 <link rel
="stylesheet" href
="themes/baggy/css/main.css" media
="all">
186 <link rel
="stylesheet" href
="themes/baggy/css/messages.css" media
="all">
187 <link rel
="stylesheet" href
="themes/baggy/css/print.css" media
="print">
188 <script src
="themes/default/js/jquery-2.0.3.min.js"></script
>
189 <script src
="themes/baggy/js/init.js"></script
>
192 <header
class="w600p center mbm">
194 <img width
="100" height
="100" src
="themes/baggy/img/logo-w.png" alt
="logo poche" />
198 <button id
="menu" class="icon icon-menu desktopHide"><span
>Menu
</span
></button
>
199 <ul id
="links" class="links">
200 <li
><a href
="http://www.wallabag.org/frequently-asked-questions/">FAQ
</a
></li
>
201 <li
><a href
="http://doc.wallabag.org/">doc
</a
></li
>
202 <li
><a href
="http://www.wallabag.org/help/">help
</a
></li
>
203 <li
><a href
="http://www.wallabag.org/">wallabag
.org
</a
></li
>
205 <?php
if (!empty($errors)) : ?>
206 <div
class='messages error install'>
207 <p
>Errors during installation
:</p
>
210 <?php
foreach($errors as $error) :?>
211 <li
><?php
echo $error; ?></li
>
215 <p
><a href
="index.php">Please reload
</a
> this page when you think you resolved these problems
.</p
>
218 <?php
if (!empty($successes)) : ?>
219 <div
class='messages success install'>
222 <?php
foreach($successes as $success) :?>
223 <li
><?php
echo $success; ?></li
>
229 <?php
if (file_exists('inc/poche/config.inc.php') && is_dir('vendor')) : ?>
230 <div
class='messages success install'>
232 wallabag seems already installed
. If you want to update it
, you only have to delete install folder
, then
<a href
="index.php">reload this page
</a
>.
237 <p
>To install wallabag
, you just have to fill the following fields
. That
's all.</p>
238 <p>Don't forget to check your server compatibility
<a href
="wallabag_compatibility_test.php?from=install">here
</a
>.</p
>
241 <legend
><strong
>Technical settings
</strong
></legend
>
242 <?php
if (!is_dir('vendor')) : ?>
243 <div
class='messages notice install'>wallabag needs twig
, a template
engine (<a href
="http://twig.sensiolabs.org/">?</a
>). Two ways to install it
:<br
/>
245 <li
>automatically download
and extract vendor
.zip into your wallabag folder
.
246 <p
><input type
="submit" name
="download" value
="Download vendor.zip" /></p
>
247 <?php
if (!extension_loaded('zip')) : ?>
248 <b
>Be careful
, zip extension is not enabled in your PHP configuration
. You
'll have to unzip vendor.zip manually.</b>
250 <em>This method is mainly recommended if you don't have a dedicated server
.</em
></li
>
251 <li
>use <a href
="http://getcomposer.org/">Composer
</a
> :<pre
><code
>curl
-s http
://getcomposer.org/installer | php
252 php composer
.phar install
</code
></pre
></li
>
259 <li
><label
for="sqlite">SQLite
</label
> <input name
="db_engine" type
="radio" checked
="" id
="sqlite" value
="sqlite" />
260 <div id
="pdo_sqlite" class='messages error install'>
261 <p
>You have to enable
<a href
="http://php.net/manual/ref.pdo-sqlite.php">pdo_sqlite extension
</a
>.</p
>
265 <label
for="mysql">MySQL
</label
> <input name
="db_engine" type
="radio" id
="mysql" value
="mysql" />
266 <ul id
="mysql_infos">
267 <li
><label
for="mysql_server">Server
</label
> <input type
="text" placeholder
="localhost" id
="mysql_server" name
="mysql_server" /></li
>
268 <li
><label
for="mysql_database">Database
</label
> <input type
="text" placeholder
="wallabag" id
="mysql_database" name
="mysql_database" /></li
>
269 <li
><label
for="mysql_user">User
</label
> <input type
="text" placeholder
="user" id
="mysql_user" name
="mysql_user" /></li
>
270 <li
><label
for="mysql_password">Password
</label
> <input type
="text" placeholder
="p4ssw0rd" id
="mysql_password" name
="mysql_password" /></li
>
274 <label
for="postgres">PostgreSQL
</label
> <input name
="db_engine" type
="radio" id
="postgres" value
="postgres" />
276 <li
><label
for="pg_server">Server
</label
> <input type
="text" placeholder
="localhost" id
="pg_server" name
="pg_server" /></li
>
277 <li
><label
for="pg_database">Database
</label
> <input type
="text" placeholder
="wallabag" id
="pg_database" name
="pg_database" /></li
>
278 <li
><label
for="pg_user">User
</label
> <input type
="text" placeholder
="user" id
="pg_user" name
="pg_user" /></li
>
279 <li
><label
for="pg_password">Password
</label
> <input type
="text" placeholder
="p4ssw0rd" id
="pg_password" name
="pg_password" /></li
>
287 <legend
><strong
>User settings
</strong
></legend
>
289 <label
for="username">Username
</label
>
290 <input type
="text" required id
="username" name
="username" value
="wallabag" />
293 <label
for="password">Password
</label
>
294 <input type
="password" required id
="password" name
="password" value
="wallabag" />
297 <label
for="show">Show password
:</label
> <input name
="show" id
="show" type
="checkbox" onchange
="document.getElementById('password').type = this.checked ? 'text' : 'password'">
301 <input type
="submit" id
="install_button" value
="Install wallabag" name
="install" />
305 $
("#mysql_infos").hide();
306 $
("#pg_infos").hide();
309 if (!extension_loaded('pdo_sqlite')) : ?>
310 $
("#install_button").hide();
314 $
("#pdo_sqlite").hide();
319 $
("input[name=db_engine]").click(function()
321 if ( $
("#mysql").prop('checked')) {
322 $
("#mysql_infos").show();
323 $
("#pg_infos").hide();
324 $
("#pdo_sqlite").hide();
325 $
("#install_button").show();
328 if ( $
("#postgres").prop('checked')) {
329 $
("#mysql_infos").hide();
330 $
("#pg_infos").show();
331 $
("#pdo_sqlite").hide();
332 $
("#install_button").show();
335 $
("#mysql_infos").hide();
336 $
("#pg_infos").hide();
338 if (!extension_loaded('pdo_sqlite')) : ?>
339 $
("#pdo_sqlite").show();
340 $
("#install_button").hide();