diff options
Diffstat (limited to 'inc/config.php')
-rw-r--r-- | inc/config.php | 76 |
1 files changed, 40 insertions, 36 deletions
diff --git a/inc/config.php b/inc/config.php index 6e3f80b8..7470f0c3 100644 --- a/inc/config.php +++ b/inc/config.php | |||
@@ -9,65 +9,69 @@ | |||
9 | */ | 9 | */ |
10 | 10 | ||
11 | define ('POCHE_VERSION', '0.3'); | 11 | define ('POCHE_VERSION', '0.3'); |
12 | |||
13 | if (!is_dir('db/')) { | ||
14 | @mkdir('db/',0705); | ||
15 | } | ||
16 | |||
17 | define ('MODE_DEMO', FALSE); | 12 | define ('MODE_DEMO', FALSE); |
18 | define ('ABS_PATH', 'assets/'); | 13 | define ('CONVERT_LINKS_FOOTNOTES', FALSE); |
19 | define ('CONVERT_LINKS_FOOTNOTES', TRUE); | 14 | define ('REVERT_FORCED_PARAGRAPH_ELEMENTS', FALSE); |
20 | define ('REVERT_FORCED_PARAGRAPH_ELEMENTS',FALSE); | 15 | define ('DOWNLOAD_PICTURES', FALSE); |
21 | define ('DOWNLOAD_PICTURES', TRUE); | ||
22 | define ('SALT', '464v54gLLw928uz4zUBqkRJeiPY68zCX'); | 16 | define ('SALT', '464v54gLLw928uz4zUBqkRJeiPY68zCX'); |
17 | define ('ABS_PATH', 'assets/'); | ||
18 | define ('TPL', './tpl'); | ||
19 | define ('LOCALE', './locale'); | ||
20 | define ('CACHE', './cache'); | ||
23 | define ('LANG', 'fr_FR.UTF8'); | 21 | define ('LANG', 'fr_FR.UTF8'); |
24 | 22 | ||
25 | putenv("LC_ALL=".LANG); | ||
26 | setlocale(LC_ALL, LANG); | ||
27 | bindtextdomain(LANG, "./locale"); | ||
28 | textdomain(LANG); | ||
29 | |||
30 | $storage_type = 'sqlite'; # sqlite or file | 23 | $storage_type = 'sqlite'; # sqlite or file |
31 | 24 | ||
32 | include 'functions.php'; | 25 | # /!\ Be careful if you change the lines below /!\ |
26 | |||
27 | require_once 'pocheCore.php'; | ||
33 | require_once 'Readability.php'; | 28 | require_once 'Readability.php'; |
34 | require_once 'Encoding.php'; | 29 | require_once 'Encoding.php'; |
35 | require_once 'rain.tpl.class.php'; | 30 | require_once 'pocheTool.class.php'; |
36 | require_once 'MyTool.class.php'; | ||
37 | require_once 'Session.class.php'; | 31 | require_once 'Session.class.php'; |
32 | require_once 'Twig/Autoloader.php'; | ||
38 | require_once 'store/store.class.php'; | 33 | require_once 'store/store.class.php'; |
39 | require_once 'store/sqlite.class.php'; | 34 | require_once 'store/' . $storage_type . '.class.php'; |
40 | require_once 'store/file.class.php'; | ||
41 | require_once 'class.messages.php'; | ||
42 | 35 | ||
43 | Session::init(); | 36 | if (DOWNLOAD_PICTURES) { |
37 | require_once 'pochePicture.php'; | ||
38 | } | ||
39 | |||
40 | # i18n | ||
41 | putenv('LC_ALL=' . LANG); | ||
42 | setlocale(LC_ALL, LANG); | ||
43 | bindtextdomain(LANG, LOCALE); | ||
44 | textdomain(LANG); | ||
45 | |||
46 | # template engine | ||
47 | Twig_Autoloader::register(); | ||
48 | $loader = new Twig_Loader_Filesystem(TPL); | ||
49 | $twig = new Twig_Environment($loader, array( | ||
50 | 'cache' => CACHE, | ||
51 | )); | ||
52 | $twig->addExtension(new Twig_Extensions_Extension_I18n()); | ||
44 | 53 | ||
45 | $store = new $storage_type(); | 54 | Session::init(); |
46 | # initialisation de RainTPL | 55 | $store = new $storage_type(); |
47 | raintpl::$tpl_dir = './tpl/'; | ||
48 | raintpl::$cache_dir = './cache/'; | ||
49 | raintpl::$base_url = get_poche_url(); | ||
50 | raintpl::configure('path_replace', false); | ||
51 | raintpl::configure('debug', false); | ||
52 | $tpl = new raintpl(); | ||
53 | 56 | ||
57 | # installation | ||
54 | if(!$store->isInstalled()) | 58 | if(!$store->isInstalled()) |
55 | { | 59 | { |
56 | logm('poche still not installed'); | 60 | pocheTool::logm('poche still not installed'); |
57 | $tpl->draw('install'); | 61 | echo $twig->render('install.twig', array( |
62 | 'token' => Session::getToken(), | ||
63 | )); | ||
58 | if (isset($_GET['install'])) { | 64 | if (isset($_GET['install'])) { |
59 | if (($_POST['password'] == $_POST['password_repeat']) | 65 | if (($_POST['password'] == $_POST['password_repeat']) |
60 | && $_POST['password'] != "" && $_POST['login'] != "") { | 66 | && $_POST['password'] != "" && $_POST['login'] != "") { |
67 | # let's rock, install poche baby ! | ||
61 | $store->install($_POST['login'], encode_string($_POST['password'] . $_POST['login'])); | 68 | $store->install($_POST['login'], encode_string($_POST['password'] . $_POST['login'])); |
62 | Session::logout(); | 69 | Session::logout(); |
63 | MyTool::redirect(); | 70 | pocheTool::redirect(); |
64 | } | 71 | } |
65 | } | 72 | } |
66 | exit(); | 73 | exit(); |
67 | } | 74 | } |
68 | 75 | ||
69 | $_SESSION['login'] = (isset ($_SESSION['login'])) ? $_SESSION['login'] : $store->getLogin(); | 76 | $_SESSION['login'] = (isset ($_SESSION['login'])) ? $_SESSION['login'] : $store->getLogin(); |
70 | $_SESSION['pass'] = (isset ($_SESSION['pass'])) ? $_SESSION['pass'] : $store->getPassword(); | 77 | $_SESSION['pass'] = (isset ($_SESSION['pass'])) ? $_SESSION['pass'] : $store->getPassword(); \ No newline at end of file |
71 | |||
72 | $msg = new Messages(); | ||
73 | $tpl->assign('msg', $msg); \ No newline at end of file | ||