mirror of
https://github.com/wallabag/wallabag.git
synced 2025-08-21 18:11:10 +00:00
merge #224
This commit is contained in:
parent
705250b93d
commit
00dbaf90bc
55 changed files with 479 additions and 884 deletions
1
inc/3rdparty/site_config
vendored
1
inc/3rdparty/site_config
vendored
|
@ -1 +0,0 @@
|
|||
Subproject commit fe9f0d3f60d44a8701f3ecab0c4077a4ed39bfe8
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,86 +10,54 @@
|
|||
|
||||
class Poche
|
||||
{
|
||||
public static $canRenderTemplates = true;
|
||||
public static $configFileAvailable = true;
|
||||
|
||||
public $user;
|
||||
public $store;
|
||||
public $tpl;
|
||||
public $messages;
|
||||
public $pagination;
|
||||
|
||||
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'))
|
||||
);
|
||||
|
||||
function __construct()
|
||||
public function __construct()
|
||||
{
|
||||
$this->initTpl();
|
||||
if (!$this->checkBeforeInstall()) {
|
||||
exit;
|
||||
if (! $this->configFileIsAvailable()) {
|
||||
return;
|
||||
}
|
||||
$this->store = new Database();
|
||||
|
||||
$this->init();
|
||||
|
||||
if (! $this->themeIsInstalled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->initTpl();
|
||||
|
||||
if (! $this->systemIsInstalled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->store = new Database();
|
||||
$this->messages = new Messages();
|
||||
|
||||
# installation
|
||||
if(!$this->store->isInstalled())
|
||||
{
|
||||
if (! $this->store->isInstalled()) {
|
||||
$this->install();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* all checks before installation.
|
||||
* @return boolean
|
||||
*/
|
||||
private function checkBeforeInstall()
|
||||
{
|
||||
$msg = '';
|
||||
$allIsGood = TRUE;
|
||||
|
||||
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 = '<h1>setup</h1><p><strong>It\'s your first time here?</strong> Please copy /install/poche.sqlite in db folder. Then, delete install folder.<br /><strong>If you have already installed poche</strong>, an update is needed <a href="install/update.php">by clicking here</a>.</p>';
|
||||
$allIsGood = FALSE;
|
||||
}
|
||||
else if (file_exists('./install') && !DEBUG_POCHE) {
|
||||
$msg = '<h1>setup</h1><p><strong>If you want to update your poche</strong>, you just have to delete /install folder. <br /><strong>To install your poche with sqlite</strong>, copy /install/poche.sqlite in /db and delete the folder /install. you have to delete the /install folder before using poche.</p>';
|
||||
$allIsGood = FALSE;
|
||||
}
|
||||
else if (STORAGE == 'sqlite' && !is_writable(STORAGE_SQLITE)) {
|
||||
Tools::logm('you don\'t have write access on sqlite file');
|
||||
$msg = '<h1>error</h1><p>You don\'t have write access on sqlite file.</p>';
|
||||
$allIsGood = FALSE;
|
||||
}
|
||||
|
||||
if (!$allIsGood) {
|
||||
echo $this->tpl->render('error.twig', array(
|
||||
'msg' => $msg
|
||||
));
|
||||
}
|
||||
|
||||
return $allIsGood;
|
||||
}
|
||||
|
||||
private function initTpl()
|
||||
{
|
||||
# template engine
|
||||
$loader = new Twig_Loader_Filesystem(TPL);
|
||||
if (DEBUG_POCHE) {
|
||||
$twig_params = array();
|
||||
}
|
||||
else {
|
||||
$twig_params = array('cache' => CACHE);
|
||||
}
|
||||
$this->tpl = new Twig_Environment($loader, $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);
|
||||
|
||||
# filter for reading time
|
||||
$filter = new Twig_SimpleFilter('getReadingTime', 'Tools::getReadingTime');
|
||||
$this->tpl->addFilter($filter);
|
||||
}
|
||||
|
||||
|
||||
private function init()
|
||||
{
|
||||
Tools::initPhp();
|
||||
|
@ -98,8 +66,7 @@ class Poche
|
|||
|
||||
if (isset($_SESSION['poche_user']) && $_SESSION['poche_user'] != array()) {
|
||||
$this->user = $_SESSION['poche_user'];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
# fake user, just for install & login screens
|
||||
$this->user = new User();
|
||||
$this->user->setConfig($this->getDefaultConfig());
|
||||
|
@ -114,13 +81,149 @@ class Poche
|
|||
|
||||
# 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 <strong>inc/poche/config.inc.php.new</strong> to <strong>inc/poche/config.inc.php</strong>.';
|
||||
|
||||
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 <a href="http://inthepoche.com/?pages/Documentation">the documentation.</a>';
|
||||
|
||||
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
|
||||
*/
|
||||
public function systemIsInstalled()
|
||||
{
|
||||
$msg = '';
|
||||
|
||||
$configSalt = defined('SALT') ? constant('SALT') : '';
|
||||
|
||||
if (empty($configSalt)) {
|
||||
$msg = '<h1>error</h1><p>You have not yet filled in the SALT value in the config.inc.php file.</p>';
|
||||
} else if (! is_writable(CACHE)) {
|
||||
Tools::logm('you don\'t have write access on cache directory');
|
||||
$msg = '<h1>error</h1><p>You don\'t have write access on cache directory.</p>';
|
||||
} else if (STORAGE == 'sqlite' && ! file_exists(STORAGE_SQLITE)) {
|
||||
Tools::logm('sqlite file doesn\'t exist');
|
||||
$msg = '<h1>error</h1><p>sqlite file doesn\'t exist, you can find it in install folder.</p>';
|
||||
} else if (file_exists(ROOT . '/install/update.php') && ! DEBUG_POCHE) {
|
||||
$msg = '<h1>setup</h1><p><strong>It\'s your first time here?</strong> Please copy /install/poche.sqlite in db folder. Then, delete install folder.<br /><strong>If you have already installed poche</strong>, an update is needed <a href="install/update.php">by clicking here</a>.</p>';
|
||||
} else if (is_dir(ROOT . '/install') && ! DEBUG_POCHE) {
|
||||
$msg = '<h1>setup</h1><p><strong>If you want to update your poche</strong>, you just have to delete /install folder. <br /><strong>To install your poche with sqlite</strong>, copy /install/poche.sqlite in /db and delete the folder /install. you have to delete the /install folder before using poche.</p>';
|
||||
} else if (STORAGE == 'sqlite' && ! is_writable(STORAGE_SQLITE)) {
|
||||
Tools::logm('you don\'t have write access on sqlite file');
|
||||
$msg = '<h1>error</h1><p>You don\'t have write access on sqlite file.</p>';
|
||||
}
|
||||
|
||||
if (! empty($msg)) {
|
||||
$this->notInstalledMessage = $msg;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getNotInstalledMessage() {
|
||||
return $this->notInstalledMessage;
|
||||
}
|
||||
|
||||
private function initTpl()
|
||||
{
|
||||
$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 {
|
||||
$twig_params = array('cache' => CACHE);
|
||||
}
|
||||
|
||||
$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);
|
||||
|
||||
# filter for reading time
|
||||
$filter = new Twig_SimpleFilter('getReadingTime', 'Tools::getReadingTime');
|
||||
$this->tpl->addFilter($filter);
|
||||
|
||||
# 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.
|
||||
|
|
|
@ -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, '<?php'."\r\n");
|
||||
fwrite($fp, "define ('POCHE_VERSION', '1.0-beta4');" . "\r\n");
|
||||
fwrite($fp, "define ('SALT', '" . md5(time() . $_SERVER['SCRIPT_FILENAME'] . rand()) . "');" . "\r\n");
|
||||
fwrite($fp, "define ('LANG', 'en_EN.utf8');" . "\r\n");
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getDocLanguage($userlanguage) {
|
||||
$lang = explode('.', $userlanguage);
|
||||
return str_replace('_', '-', $lang[0]);
|
||||
|
|
|
@ -3,49 +3,54 @@
|
|||
* poche, a read it later open source system
|
||||
*
|
||||
* @category poche
|
||||
* @author Nicolas Lœuillet <support@inthepoche.com>
|
||||
* @author Nicolas Lœuillet <nicolas@loeuillet.org>
|
||||
* @copyright 2013
|
||||
* @license http://www.wtfpl.net/ see COPYING file
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../../inc/poche/define.inc.php';
|
||||
define ('SALT', ''); # put a strong string here
|
||||
define ('LANG', 'en_EN.utf8');
|
||||
|
||||
# /!\ 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 <a href="inthepoche.com/doc">the documentation.</a>');
|
||||
}
|
||||
define ('STORAGE', 'sqlite'); # postgres, mysql or sqlite
|
||||
|
||||
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';
|
||||
define ('STORAGE_SQLITE', ROOT . '/db/poche.sqlite'); # if you are using sqlite, where the database file is located
|
||||
|
||||
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';
|
||||
# only for postgres & mysql
|
||||
define ('STORAGE_SERVER', 'localhost');
|
||||
define ('STORAGE_DB', 'poche');
|
||||
define ('STORAGE_USER', 'poche');
|
||||
define ('STORAGE_PASSWORD', 'poche');
|
||||
|
||||
if (DOWNLOAD_PICTURES) {
|
||||
require_once __DIR__ . '/../../inc/poche/pochePictures.php';
|
||||
}
|
||||
#################################################################################
|
||||
# Do not trespass unless you know what you are doing
|
||||
#################################################################################
|
||||
|
||||
if (!ini_get('date.timezone') || !@date_default_timezone_set(ini_get('date.timezone'))) {
|
||||
date_default_timezone_set('UTC');
|
||||
}
|
||||
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/');
|
||||
|
||||
$poche = new Poche();
|
||||
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');
|
56
inc/poche/config.inc.php.new
Executable file
56
inc/poche/config.inc.php.new
Executable file
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
/**
|
||||
* poche, a read it later open source system
|
||||
*
|
||||
* @category poche
|
||||
* @author Nicolas Lœuillet <nicolas@loeuillet.org>
|
||||
* @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');
|
72
inc/poche/global.inc.php
Normal file
72
inc/poche/global.inc.php
Normal file
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
/**
|
||||
* poche, a read it later open source system
|
||||
*
|
||||
* @category poche
|
||||
* @author Nicolas Lœuillet <nicolas@loeuillet.org>
|
||||
* @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']);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue