-
+
- FAQ +
- doc +
- help +
- wallabag.org +
To install wallabag, you just have to fill the following fields. That's all.
+Don't forget to check your server compatibility here.
+ +diff --git a/check_setup.php b/check_setup.php new file mode 100644 index 000000000..96dd0f7d4 --- /dev/null +++ b/check_setup.php @@ -0,0 +1,40 @@ + "short_open_tag = On"'); + } +} + +// Check PDO Sqlite +if (! extension_loaded('pdo_sqlite')) { + die('PHP extension required: pdo_sqlite'); +} + +// Check ZIP +if (! extension_loaded('zip')) { + die('PHP extension required: zip'); +} + +// Check if /cache is writeable +if (! is_writable('cache')) { + die('The directory "cache" must be writeable by your web server user'); +} + +// Check if /db is writeable +if (! is_writable('db')) { + die('The directory "db" must be writeable by your web server user'); +} + +// install folder still present, need to install wallabag +if (is_dir('install')) { + require('install/index.php'); + exit; +} \ No newline at end of file diff --git a/index.php b/index.php index 1a595ecef..7ded3bdbc 100644 --- a/index.php +++ b/index.php @@ -9,6 +9,7 @@ */ define ('POCHE', '1.5.0'); +require 'check_setup.php'; require_once 'inc/poche/global.inc.php'; session_start(); diff --git a/install/index.php b/install/index.php new file mode 100644 index 000000000..d21371722 --- /dev/null +++ b/install/index.php @@ -0,0 +1,283 @@ +download it here manually<∕a> and unzip it in your wallabag folder.'; + } + else { + if (extension_loaded('zip')) { + $zip = new ZipArchive(); + if ($zip->open("cache/vendor.zip") !== TRUE){ + $errors[] = 'Impossible to open cache/vendor.zip. Please unzip it manually in your wallabag folder.'; + } + if ($zip->extractTo(realpath(''))) { + @unlink("cache/vendor.zip"); + $successes[] = 'twig is now installed, you can install wallabag.'; + } + else { + $errors[] = 'Impossible to extract cache/vendor.zip. Please unzip it manually in your wallabag folder.'; + } + $zip->close(); + } + else { + $errors[] = 'zip extension is not enabled in your PHP configuration. Please unzip cache/vendor.zip in your wallabag folder.'; + } + } +} +else if ($_POST['install']) { + if (!is_dir('vendor')) { + $errors[] = 'You must install twig before.'; + } + else { + $continue = true; + // Create config.inc.php + if (!copy('inc/poche/config.inc.php.new', 'inc/poche/config.inc.php')) { + $errors[] = 'Installation aborted, impossible to create inc/poche/config.inc.php file. Maybe you don\'t have write access to create it.'; + $continue = false; + } + else { + function generate_salt() { + mt_srand(microtime(true)*100000 + memory_get_usage(true)); + return md5(uniqid(mt_rand(), true)); + } + + $content = file_get_contents('inc/poche/config.inc.php'); + $salt = generate_salt(); + $content = str_replace("define ('SALT', '');", "define ('SALT', '".$salt."');", $content); + file_put_contents('inc/poche/config.inc.php', $content); + } + + if ($continue) { + + // User informations + $username = trim($_POST['username']); + $password = trim($_POST['password']); + $salted_password = sha1($password . $username . $salt); + + // Database informations + if ($_POST['db_engine'] == 'sqlite') { + if (!copy('install/poche.sqlite', 'db/poche.sqlite')) { + $errors[] = 'Impossible to create inc/poche/config.inc.php file.'; + $continue = false; + } + else { + $db_path = 'sqlite:' . realpath('') . '/db/poche.sqlite'; + $handle = new PDO($db_path); + } + } + else { + $content = file_get_contents('inc/poche/config.inc.php'); + + if ($_POST['db_engine'] == 'mysql') { + $db_path = 'mysql:host=' . $_POST['mysql_server'] . ';dbname=' . $_POST['mysql_database']; + $content = str_replace("define ('STORAGE_SERVER', 'localhost');", "define ('STORAGE_SERVER', '".$_POST['mysql_server']."');", $content); + $content = str_replace("define ('STORAGE_DB', 'poche');", "define ('STORAGE_DB', '".$_POST['mysql_database']."');", $content); + $content = str_replace("define ('STORAGE_USER', 'poche');", "define ('STORAGE_USER', '".$_POST['mysql_user']."');", $content); + $content = str_replace("define ('STORAGE_PASSWORD', 'poche');", "define ('STORAGE_PASSWORD', '".$_POST['mysql_password']."');", $content); + $handle = new PDO($db_path, $_POST['mysql_user'], $_POST['mysql_password']); + + $sql_structure = file_get_contents('install/mysql.sql'); + } + else if ($_POST['db_engine'] == 'postgresql') { + $db_path = 'pgsql:host=' . $_POST['pg_server'] . ';dbname=' . $_POST['pg_database']; + $content = str_replace("define ('STORAGE_SERVER', 'localhost');", "define ('STORAGE_SERVER', '".$_POST['pg_server']."');", $content); + $content = str_replace("define ('STORAGE_DB', 'poche');", "define ('STORAGE_DB', '".$_POST['pg_database']."');", $content); + $content = str_replace("define ('STORAGE_USER', 'poche');", "define ('STORAGE_USER', '".$_POST['pg_user']."');", $content); + $content = str_replace("define ('STORAGE_PASSWORD', 'poche');", "define ('STORAGE_PASSWORD', '".$_POST['pg_password']."');", $content); + $handle = new PDO($db_path, $_POST['pg_user'], $_POST['pg_password']); + + $sql_structure = file_get_contents('install/postgres.sql'); + } + + $content = str_replace("define ('STORAGE', 'sqlite');", "define ('STORAGE', '".$_POST['db_engine']."');", $content); + file_put_contents('inc/poche/config.inc.php', $content); + } + + if ($continue) { + + function executeQuery($handle, $sql, $params) { + try + { + $query = $handle->prepare($sql); + $query->execute($params); + return $query->fetchAll(); + } + catch (Exception $e) + { + return FALSE; + } + } + + // create database structure + $query = executeQuery($handle, $sql_structure, array()); + + // Create user + $handle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + $sql = 'INSERT INTO users (username, password, name) VALUES (?, ?, ?)'; + $params = array($username, $salted_password, $username); + $query = executeQuery($handle, $sql, $params); + + $id_user = $handle->lastInsertId(); + + $sql = 'INSERT INTO users_config ( user_id, name, value ) VALUES (?, ?, ?)'; + $params = array($id_user, 'pager', '10'); + $query = executeQuery($handle, $sql, $params); + + $sql = 'INSERT INTO users_config ( user_id, name, value ) VALUES (?, ?, ?)'; + $params = array($id_user, 'language', 'en_EN.UTF8'); + $query = executeQuery($handle, $sql, $params); + + $successes[] = 'wallabag is now installed. Don\'t forget to delete install folder.'; + } + } + } +} +?> + + +
+ + + +To install wallabag, you just have to fill the following fields. That's all.
+Don't forget to check your server compatibility here.
+ +