From 00dbaf90bc44ef3ed0abaebb15307756e054a027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 20 Sep 2013 10:21:39 +0200 Subject: merge #224 --- inc/3rdparty/site_config | 1 - inc/poche/Database.class.php | 16 ++- inc/poche/Poche.class.php | 293 ++++++++++++++++++++++++++++++++++--------- inc/poche/Tools.class.php | 40 +++--- inc/poche/config.inc.php | 89 ++++++------- inc/poche/config.inc.php.new | 56 +++++++++ inc/poche/global.inc.php | 72 +++++++++++ 7 files changed, 435 insertions(+), 132 deletions(-) delete mode 160000 inc/3rdparty/site_config create mode 100755 inc/poche/config.inc.php.new create mode 100644 inc/poche/global.inc.php (limited to 'inc') diff --git a/inc/3rdparty/site_config b/inc/3rdparty/site_config deleted file mode 160000 index fe9f0d3f..00000000 --- a/inc/3rdparty/site_config +++ /dev/null @@ -1 +0,0 @@ -Subproject commit fe9f0d3f60d44a8701f3ecab0c4077a4ed39bfe8 diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php index 84916b83..4d664992 100644 --- a/inc/poche/Database.class.php +++ b/inc/poche/Database.class.php @@ -60,11 +60,15 @@ class Database { $id_user = intval($this->getLastId($sequence)); $sql = 'INSERT INTO users_config ( user_id, name, value ) VALUES (?, ?, ?)'; - $params = array($id_user, 'pager', '10'); + $params = array($id_user, 'pager', PAGINATION); $query = $this->executeQuery($sql, $params); $sql = 'INSERT INTO users_config ( user_id, name, value ) VALUES (?, ?, ?)'; - $params = array($id_user, 'language', 'en_EN.UTF8'); + $params = array($id_user, 'language', LANG); + $query = $this->executeQuery($sql, $params); + + $sql = 'INSERT INTO users_config ( user_id, name, value ) VALUES (?, ?, ?)'; + $params = array($id_user, 'theme', DEFAULT_THEME); $query = $this->executeQuery($sql, $params); return TRUE; @@ -101,10 +105,16 @@ class Database { return $user; } - public function updatePassword($id, $password) + public function updatePassword($userId, $password) { $sql_update = "UPDATE users SET password=? WHERE id=?"; $params_update = array($password, $id); + $this->updateUserConfig($userId, 'password', $password); + } + + public function updateUserConfig($userId, $key, $value) { + $sql_update = "UPDATE users_config SET `value`=? WHERE `user_id`=? AND `name`=?"; + $params_update = array($value, $userId, $key); $query = $this->executeQuery($sql_update, $params_update); } diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 8770c7f7..67fbd529 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -10,77 +10,200 @@ class Poche { + public static $canRenderTemplates = true; + public static $configFileAvailable = true; + public $user; public $store; public $tpl; public $messages; public $pagination; - - function __construct() + + private $currentTheme = ''; + private $notInstalledMessage = ''; + + # @todo make this dynamic (actually install themes and save them in the database including author information et cetera) + private $installedThemes = array( + 'default' => array('requires' => array()), + 'dark' => array('requires' => array('default')), + 'dmagenta' => array('requires' => array('default')), + 'solarized' => array('requires' => array('default')), + 'solarized-dark' => array('requires' => array('default')) + ); + + public function __construct() { + if (! $this->configFileIsAvailable()) { + return; + } + + $this->init(); + + if (! $this->themeIsInstalled()) { + return; + } + $this->initTpl(); - if (!$this->checkBeforeInstall()) { - exit; + + if (! $this->systemIsInstalled()) { + return; } + $this->store = new Database(); - $this->init(); $this->messages = new Messages(); # installation - if(!$this->store->isInstalled()) - { + if (! $this->store->isInstalled()) { $this->install(); } } + + private function init() + { + Tools::initPhp(); + Session::$sessionName = 'poche'; + Session::init(); + + if (isset($_SESSION['poche_user']) && $_SESSION['poche_user'] != array()) { + $this->user = $_SESSION['poche_user']; + } else { + # fake user, just for install & login screens + $this->user = new User(); + $this->user->setConfig($this->getDefaultConfig()); + } + + # l10n + $language = $this->user->getConfigValue('language'); + putenv('LC_ALL=' . $language); + setlocale(LC_ALL, $language); + bindtextdomain($language, LOCALE); + textdomain($language); + + # Pagination + $this->pagination = new Paginator($this->user->getConfigValue('pager'), 'p'); + + # Set up theme + $themeDirectory = $this->user->getConfigValue('theme'); + + if ($themeDirectory === false) { + $themeDirectory = DEFAULT_THEME; + } + + $this->currentTheme = $themeDirectory; + } + + public function configFileIsAvailable() { + if (! self::$configFileAvailable) { + $this->notInstalledMessage = 'You have to rename inc/poche/config.inc.php.new to inc/poche/config.inc.php.'; + + return false; + } + return true; + } + + public function themeIsInstalled() { + # Twig is an absolute requirement for Poche to function. Abort immediately if the Composer installer hasn't been run yet + if (! self::$canRenderTemplates) { + $this->notInstalledMessage = 'Twig does not seem to be installed. Please initialize the Composer installation to automatically fetch dependencies. Have a look at the documentation.'; + + return false; + } + + # Check if the selected theme and its requirements are present + if (! is_dir(THEME . '/' . $this->getTheme())) { + $this->notInstalledMessage = 'The currently selected theme (' . $this->getTheme() . ') does not seem to be properly installed (Missing directory: ' . THEME . '/' . $this->getTheme() . ')'; + + self::$canRenderTemplates = false; + + return false; + } + + foreach ($this->installedThemes[$this->getTheme()]['requires'] as $requiredTheme) { + if (! is_dir(THEME . '/' . $requiredTheme)) { + $this->notInstalledMessage = 'The required "' . $requiredTheme . '" theme is missing for the current theme (' . $this->getTheme() . ')'; + + self::$canRenderTemplates = false; + + return false; + } + } + + return true; + } + /** * all checks before installation. + * @todo move HTML to template * @return boolean */ - private function checkBeforeInstall() + public function systemIsInstalled() { $msg = ''; - $allIsGood = TRUE; - - if (!is_writable(CACHE)) { + + $configSalt = defined('SALT') ? constant('SALT') : ''; + + if (empty($configSalt)) { + $msg = '

error

You have not yet filled in the SALT value in the config.inc.php file.

'; + } else if (! is_writable(CACHE)) { Tools::logm('you don\'t have write access on cache directory'); - die('You don\'t have write access on cache directory.'); - } - else if (file_exists('./install/update.php') && !DEBUG_POCHE) { + $msg = '

error

You don\'t have write access on cache directory.

'; + } else if (STORAGE == 'sqlite' && ! file_exists(STORAGE_SQLITE)) { + Tools::logm('sqlite file doesn\'t exist'); + $msg = '

error

sqlite file doesn\'t exist, you can find it in install folder.

'; + } else if (file_exists(ROOT . '/install/update.php') && ! DEBUG_POCHE) { $msg = '

setup

It\'s your first time here? Please copy /install/poche.sqlite in db folder. Then, delete install folder.
If you have already installed poche, an update is needed by clicking here.

'; - $allIsGood = FALSE; - } - else if (file_exists('./install') && !DEBUG_POCHE) { + } else if (is_dir(ROOT . '/install') && ! DEBUG_POCHE) { $msg = '

setup

If you want to update your poche, you just have to delete /install folder.
To install your poche with sqlite, copy /install/poche.sqlite in /db and delete the folder /install. you have to delete the /install folder before using poche.

'; - $allIsGood = FALSE; - } - else if (STORAGE == 'sqlite' && !is_writable(STORAGE_SQLITE)) { + } else if (STORAGE == 'sqlite' && ! is_writable(STORAGE_SQLITE)) { Tools::logm('you don\'t have write access on sqlite file'); $msg = '

error

You don\'t have write access on sqlite file.

'; - $allIsGood = FALSE; } - - if (!$allIsGood) { - echo $this->tpl->render('error.twig', array( - 'msg' => $msg - )); + + if (! empty($msg)) { + $this->notInstalledMessage = $msg; + + return false; } - return $allIsGood; + return true; + } + + public function getNotInstalledMessage() { + return $this->notInstalledMessage; } private function initTpl() { - # template engine - $loader = new Twig_Loader_Filesystem(TPL); + $loaderChain = new Twig_Loader_Chain(); + + # add the current theme as first to the loader chain so Twig will look there first for overridden template files + try { + $loaderChain->addLoader(new Twig_Loader_Filesystem(THEME . '/' . $this->getTheme())); + } catch (Twig_Error_Loader $e) { + # @todo isInstalled() should catch this, inject Twig later + die('The currently selected theme (' . $this->getTheme() . ') does not seem to be properly installed (' . THEME . '/' . $this->getTheme() .' is missing)'); + } + + # add all required themes to the loader chain + foreach ($this->installedThemes[$this->getTheme()]['requires'] as $requiredTheme) { + try { + $loaderChain->addLoader(new Twig_Loader_Filesystem(THEME . '/' . DEFAULT_THEME)); + } catch (Twig_Error_Loader $e) { + # @todo isInstalled() should catch this, inject Twig later + die('The required "' . $requiredTheme . '" theme is missing for the current theme (' . $this->getTheme() . ')'); + } + } + if (DEBUG_POCHE) { $twig_params = array(); - } - else { + } else { $twig_params = array('cache' => CACHE); } - $this->tpl = new Twig_Environment($loader, $twig_params); + + $this->tpl = new Twig_Environment($loaderChain, $twig_params); $this->tpl->addExtension(new Twig_Extensions_Extension_I18n()); + # filter to display domain name of an url $filter = new Twig_SimpleFilter('getDomain', 'Tools::getDomain'); $this->tpl->addFilter($filter); @@ -88,39 +211,19 @@ class Poche # filter for reading time $filter = new Twig_SimpleFilter('getReadingTime', 'Tools::getReadingTime'); $this->tpl->addFilter($filter); - } - - private function init() - { - Tools::initPhp(); - Session::$sessionName = 'poche'; - Session::init(); - - if (isset($_SESSION['poche_user']) && $_SESSION['poche_user'] != array()) { - $this->user = $_SESSION['poche_user']; - } - else { - # fake user, just for install & login screens - $this->user = new User(); - $this->user->setConfig($this->getDefaultConfig()); - } - - # l10n - $language = $this->user->getConfigValue('language'); - putenv('LC_ALL=' . $language); - setlocale(LC_ALL, $language); - bindtextdomain($language, LOCALE); - textdomain($language); - - # Pagination - $this->pagination = new Paginator($this->user->getConfigValue('pager'), 'p'); + + # filter for simple filenames in config view + $filter = new Twig_SimpleFilter('getPrettyFilename', function($string) { return str_replace(ROOT, '', $string); }); + $this->tpl->addFilter($filter); } private function install() { Tools::logm('poche still not installed'); echo $this->tpl->render('install.twig', array( - 'token' => Session::getToken() + 'token' => Session::getToken(), + 'theme' => $this->getTheme(), + 'poche_url' => Tools::getPocheUrl() )); if (isset($_GET['install'])) { if (($_POST['password'] == $_POST['password_repeat']) @@ -140,13 +243,41 @@ class Poche } exit(); } + + public function getTheme() { + return $this->currentTheme; + } + + public function getInstalledThemes() { + $handle = opendir(THEME); + $themes = array(); + + while (($theme = readdir($handle)) !== false) { + # Themes are stored in a directory, so all directory names are themes + # @todo move theme installation data to database + if (! is_dir(THEME . '/' . $theme) || in_array($theme, array('..', '.'))) { + continue; + } + + $current = false; + + if ($theme === $this->getTheme()) { + $current = true; + } + + $themes[] = array('name' => $theme, 'current' => $current); + } + + return $themes; + } public function getDefaultConfig() - { + { return array( 'pager' => PAGINATION, 'language' => LANG, - ); + 'theme' => DEFAULT_THEME + ); } /** @@ -231,7 +362,9 @@ class Poche $prod = $this->getPocheVersion('prod'); $compare_dev = version_compare(POCHE_VERSION, $dev); $compare_prod = version_compare(POCHE_VERSION, $prod); + $themes = $this->getInstalledThemes(); $tpl_vars = array( + 'themes' => $themes, 'dev' => $dev, 'prod' => $prod, 'compare_dev' => $compare_dev, @@ -316,6 +449,44 @@ class Poche } } } + + public function updateTheme() + { + # no data + if (empty($_POST['theme'])) { + } + + # we are not going to change it to the current theme... + if ($_POST['theme'] == $this->getTheme()) { + $this->messages->add('w', _('still using the "' . $this->getTheme() . '" theme!')); + Tools::redirect('?view=config'); + } + + $themes = $this->getInstalledThemes(); + $actualTheme = false; + + foreach ($themes as $theme) { + if ($theme['name'] == $_POST['theme']) { + $actualTheme = true; + break; + } + } + + if (! $actualTheme) { + $this->messages->add('e', _('that theme does not seem to be installed')); + Tools::redirect('?view=config'); + } + + $this->store->updateUserConfig($this->user->getId(), 'theme', $_POST['theme']); + $this->messages->add('s', _('you have changed your theme preferences')); + + $currentConfig = $_SESSION['poche_user']->config; + $currentConfig['theme'] = $_POST['theme']; + + $_SESSION['poche_user']->setConfig($currentConfig); + + Tools::redirect('?view=config'); + } /** * checks if login & password are correct and save the user in session. diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index 1ab90be1..8eb988f4 100644 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -84,9 +84,9 @@ class Tools public static function getTplFile($view) { - $tpl_file = 'home.twig'; - switch ($view) - { + $default_tpl = 'home.twig'; + + switch ($view) { case 'install': $tpl_file = 'install.twig'; break; @@ -102,9 +102,20 @@ class Tools case 'view': $tpl_file = 'view.twig'; break; + + case 'login': + $tpl_file = 'login.twig'; + break; + + case 'error': + $tpl_file = 'error.twig'; + break; + default: - break; + $tpl_file = $default_tpl; + break; } + return $tpl_file; } @@ -228,27 +239,6 @@ class Tools return $minutes; } - - public static function createMyConfig() - { - $myconfig_file = './inc/poche/myconfig.inc.php'; - - if (!is_writable('./inc/poche/')) { - self::logm('you don\'t have write access to create ./inc/poche/myconfig.inc.php'); - die('You don\'t have write access to create ./inc/poche/myconfig.inc.php.'); - } - - if (!file_exists($myconfig_file)) - { - $fp = fopen($myconfig_file, 'w'); - fwrite($fp, ' + * @author Nicolas Lœuillet * @copyright 2013 * @license http://www.wtfpl.net/ see COPYING file */ -require_once __DIR__ . '/../../inc/poche/define.inc.php'; - -# /!\ Be careful if you change the lines below /!\ -if (!file_exists(__DIR__ . '/../../vendor/autoload.php')) { - die('Twig does not seem installed. Have a look at the documentation.'); -} - -require_once __DIR__ . '/../../inc/poche/User.class.php'; -require_once __DIR__ . '/../../inc/poche/Url.class.php'; -require_once __DIR__ . '/../../inc/3rdparty/class.messages.php'; -require_once __DIR__ . '/../../inc/poche/Poche.class.php'; -require_once __DIR__ . '/../../inc/3rdparty/Readability.php'; -require_once __DIR__ . '/../../inc/poche/PocheReadability.php'; -require_once __DIR__ . '/../../inc/3rdparty/Encoding.php'; -require_once __DIR__ . '/../../inc/poche/Database.class.php'; -require_once __DIR__ . '/../../vendor/autoload.php'; -require_once __DIR__ . '/../../inc/3rdparty/simple_html_dom.php'; -require_once __DIR__ . '/../../inc/3rdparty/paginator.php'; -require_once __DIR__ . '/../../inc/3rdparty/Session.class.php'; - -require_once __DIR__ . '/../../inc/3rdparty/simplepie/SimplePieAutoloader.php'; -require_once __DIR__ . '/../../inc/3rdparty/simplepie/SimplePie/Core.php'; -require_once __DIR__ . '/../../inc/3rdparty/content-extractor/ContentExtractor.php'; -require_once __DIR__ . '/../../inc/3rdparty/content-extractor/SiteConfig.php'; -require_once __DIR__ . '/../../inc/3rdparty/humble-http-agent/HumbleHttpAgent.php'; -require_once __DIR__ . '/../../inc/3rdparty/humble-http-agent/SimplePie_HumbleHttpAgent.php'; -require_once __DIR__ . '/../../inc/3rdparty/humble-http-agent/CookieJar.php'; -require_once __DIR__ . '/../../inc/3rdparty/feedwriter/FeedItem.php'; -require_once __DIR__ . '/../../inc/3rdparty/feedwriter/FeedWriter.php'; -require_once __DIR__ . '/../../inc/3rdparty/feedwriter/DummySingleItemFeed.php'; -require_once __DIR__ . '/../../inc/3rdparty/FlattrItem.class.php'; - -if (DOWNLOAD_PICTURES) { - require_once __DIR__ . '/../../inc/poche/pochePictures.php'; -} - -if (!ini_get('date.timezone') || !@date_default_timezone_set(ini_get('date.timezone'))) { - date_default_timezone_set('UTC'); -} - -$poche = new Poche(); \ No newline at end of file +define ('SALT', ''); # put a strong string here +define ('LANG', 'en_EN.utf8'); + +define ('STORAGE', 'sqlite'); # postgres, mysql or sqlite + +define ('STORAGE_SQLITE', ROOT . '/db/poche.sqlite'); # if you are using sqlite, where the database file is located + +# only for postgres & mysql +define ('STORAGE_SERVER', 'localhost'); +define ('STORAGE_DB', 'poche'); +define ('STORAGE_USER', 'poche'); +define ('STORAGE_PASSWORD', 'poche'); + +################################################################################# +# Do not trespass unless you know what you are doing +################################################################################# + +define ('MODE_DEMO', FALSE); +define ('DEBUG_POCHE', true); +define ('DOWNLOAD_PICTURES', FALSE); +define ('CONVERT_LINKS_FOOTNOTES', FALSE); +define ('REVERT_FORCED_PARAGRAPH_ELEMENTS', FALSE); +define ('SHARE_TWITTER', TRUE); +define ('SHARE_MAIL', TRUE); +define ('SHARE_SHAARLI', FALSE); +define ('SHAARLI_URL', 'http://myshaarliurl.com'); +define ('FLATTR', TRUE); +define ('FLATTR_API', 'https://api.flattr.com/rest/v2/things/lookup/?url='); +define ('NOT_FLATTRABLE', '0'); +define ('FLATTRABLE', '1'); +define ('FLATTRED', '2'); +define ('ABS_PATH', 'assets/'); + +define ('DEFAULT_THEME', 'default'); + +define ('THEME', ROOT . '/themes'); +define ('LOCALE', ROOT . '/locale'); +define ('CACHE', ROOT . '/cache'); + +define ('PAGINATION', '10'); + +define ('POCHE_VERSION', '1.0-beta5'); + +define ('IMPORT_POCKET_FILE', ROOT . '/ril_export.html'); +define ('IMPORT_READABILITY_FILE', ROOT . '/readability'); +define ('IMPORT_INSTAPAPER_FILE', ROOT . '/instapaper-export.html'); \ No newline at end of file diff --git a/inc/poche/config.inc.php.new b/inc/poche/config.inc.php.new new file mode 100755 index 00000000..5c304d14 --- /dev/null +++ b/inc/poche/config.inc.php.new @@ -0,0 +1,56 @@ + + * @copyright 2013 + * @license http://www.wtfpl.net/ see COPYING file + */ + +define ('SALT', ''); # put a strong string here +define ('LANG', 'en_EN.utf8'); + +define ('STORAGE', 'sqlite'); # postgres, mysql or sqlite + +define ('STORAGE_SQLITE', ROOT . '/db/poche.sqlite'); # if you are using sqlite, where the database file is located + +# only for postgres & mysql +define ('STORAGE_SERVER', 'localhost'); +define ('STORAGE_DB', 'poche'); +define ('STORAGE_USER', 'poche'); +define ('STORAGE_PASSWORD', 'poche'); + +################################################################################# +# Do not trespass unless you know what you are doing +################################################################################# + +define ('MODE_DEMO', FALSE); +define ('DEBUG_POCHE', true); +define ('DOWNLOAD_PICTURES', FALSE); +define ('CONVERT_LINKS_FOOTNOTES', FALSE); +define ('REVERT_FORCED_PARAGRAPH_ELEMENTS', FALSE); +define ('SHARE_TWITTER', TRUE); +define ('SHARE_MAIL', TRUE); +define ('SHARE_SHAARLI', FALSE); +define ('SHAARLI_URL', 'http://myshaarliurl.com'); +define ('FLATTR', TRUE); +define ('FLATTR_API', 'https://api.flattr.com/rest/v2/things/lookup/?url='); +define ('NOT_FLATTRABLE', '0'); +define ('FLATTRABLE', '1'); +define ('FLATTRED', '2'); +define ('ABS_PATH', 'assets/'); + +define ('DEFAULT_THEME', 'default'); + +define ('THEME', ROOT . '/themes'); +define ('LOCALE', ROOT . '/locale'); +define ('CACHE', ROOT . '/cache'); + +define ('PAGINATION', '10'); + +define ('POCHE_VERSION', '1.0-beta5'); + +define ('IMPORT_POCKET_FILE', ROOT . '/ril_export.html'); +define ('IMPORT_READABILITY_FILE', ROOT . '/readability'); +define ('IMPORT_INSTAPAPER_FILE', ROOT . '/instapaper-export.html'); \ No newline at end of file diff --git a/inc/poche/global.inc.php b/inc/poche/global.inc.php new file mode 100644 index 00000000..2437d065 --- /dev/null +++ b/inc/poche/global.inc.php @@ -0,0 +1,72 @@ + + * @copyright 2013 + * @license http://www.wtfpl.net/ see COPYING file + */ + +# the poche system root directory (/inc) +define('INCLUDES', dirname(__FILE__) . '/..'); + +# the poche root directory +define('ROOT', INCLUDES . '/..'); + +require_once INCLUDES . '/poche/Tools.class.php'; +require_once INCLUDES . '/poche/User.class.php'; +require_once INCLUDES . '/poche/Url.class.php'; +require_once INCLUDES . '/3rdparty/class.messages.php'; +require_once INCLUDES . '/poche/Poche.class.php'; + +require_once INCLUDES . '/3rdparty/Readability.php'; +require_once INCLUDES . '/poche/PocheReadability.php'; + +require_once INCLUDES . '/3rdparty/Encoding.php'; +require_once INCLUDES . '/poche/Database.class.php'; +require_once INCLUDES . '/3rdparty/simple_html_dom.php'; +require_once INCLUDES . '/3rdparty/paginator.php'; +require_once INCLUDES . '/3rdparty/Session.class.php'; + +require_once INCLUDES . '/3rdparty/simplepie/SimplePieAutoloader.php'; +require_once INCLUDES . '/3rdparty/simplepie/SimplePie/Core.php'; +require_once INCLUDES . '/3rdparty/content-extractor/ContentExtractor.php'; +require_once INCLUDES . '/3rdparty/content-extractor/SiteConfig.php'; +require_once INCLUDES . '/3rdparty/humble-http-agent/HumbleHttpAgent.php'; +require_once INCLUDES . '/3rdparty/humble-http-agent/SimplePie_HumbleHttpAgent.php'; +require_once INCLUDES . '/3rdparty/humble-http-agent/CookieJar.php'; +require_once INCLUDES . '/3rdparty/feedwriter/FeedItem.php'; +require_once INCLUDES . '/3rdparty/feedwriter/FeedWriter.php'; +require_once INCLUDES . '/3rdparty/feedwriter/DummySingleItemFeed.php'; +require_once INCLUDES . '/3rdparty/FlattrItem.class.php'; + +# Composer its autoloader for automatically loading Twig +if (! file_exists(ROOT . '/vendor/autoload.php')) { + Poche::$canRenderTemplates = false; +} else { + require_once ROOT . '/vendor/autoload.php'; +} + +# system configuration; database credentials et cetera +if (! file_exists(INCLUDES . '/poche/config.inc.php')) { + Poche::$configFileAvailable = false; +} else { + require_once INCLUDES . '/poche/config.inc.php'; +} + +if (Poche::$configFileAvailable && DOWNLOAD_PICTURES) { + require_once INCLUDES . '/poche/pochePictures.php'; +} + +if (!ini_get('date.timezone') || !@date_default_timezone_set(ini_get('date.timezone'))) { + date_default_timezone_set('UTC'); +} + +#XSRF protection with token +if (!empty($_POST)) { + if (!Session::isToken($_POST['token'])) { + die(_('Wrong token')); + } + unset($_SESSION['token']); +} \ No newline at end of file -- cgit v1.2.3