From 26b77483ee7545c0e4f8eeb205a5743bf3589adb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Sat, 12 Jul 2014 16:39:31 +0200 Subject: [PATCH] remove PicoFarad MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I’ll implement it an other day. --- inc/3rdparty/PicoFarad/Request.php | 78 -------------- inc/3rdparty/PicoFarad/Response.php | 156 --------------------------- inc/3rdparty/PicoFarad/Router.php | 157 ---------------------------- inc/3rdparty/PicoFarad/Session.php | 57 ---------- inc/3rdparty/PicoFarad/Template.php | 36 ------- inc/poche/Routing.class.php | 8 +- inc/poche/global.inc.php | 13 --- index.php | 57 +--------- 8 files changed, 9 insertions(+), 553 deletions(-) delete mode 100644 inc/3rdparty/PicoFarad/Request.php delete mode 100644 inc/3rdparty/PicoFarad/Response.php delete mode 100644 inc/3rdparty/PicoFarad/Router.php delete mode 100644 inc/3rdparty/PicoFarad/Session.php delete mode 100644 inc/3rdparty/PicoFarad/Template.php diff --git a/inc/3rdparty/PicoFarad/Request.php b/inc/3rdparty/PicoFarad/Request.php deleted file mode 100644 index 46c82bc..0000000 --- a/inc/3rdparty/PicoFarad/Request.php +++ /dev/null @@ -1,78 +0,0 @@ - $_FILES[$field]['name'], - 'mimetype' => $_FILES[$field]['type'], - 'size' => $_FILES[$field]['size'], - ); - } - - return false; -} - - -function file_move($field, $destination) -{ - if (isset($_FILES[$field]) && ! file_exists($destination)) { - @mkdir(dirname($destination), 0777, true); - move_uploaded_file($_FILES[$field]['tmp_name'], $destination); - } -} \ No newline at end of file diff --git a/inc/3rdparty/PicoFarad/Response.php b/inc/3rdparty/PicoFarad/Response.php deleted file mode 100644 index 9114fde..0000000 --- a/inc/3rdparty/PicoFarad/Response.php +++ /dev/null @@ -1,156 +0,0 @@ - $hosts) { - - if (is_array($hosts)) { - - $acl = ''; - - foreach ($hosts as &$host) { - - if ($host === '*' || $host === 'self' || strpos($host, 'http') === 0) { - $acl .= $host.' '; - } - } - } - else { - - $acl = $hosts; - } - - $values .= $policy.' '.trim($acl).'; '; - } - - header('Content-Security-Policy: '.$values); -} - - -function nosniff() -{ - header('X-Content-Type-Options: nosniff'); -} - - -function xss() -{ - header('X-XSS-Protection: 1; mode=block'); -} - - -function hsts() -{ - header('Strict-Transport-Security: max-age=31536000'); -} - - -function xframe($mode = 'DENY', array $urls = array()) -{ - header('X-Frame-Options: '.$mode.' '.implode(' ', $urls)); -} \ No newline at end of file diff --git a/inc/3rdparty/PicoFarad/Router.php b/inc/3rdparty/PicoFarad/Router.php deleted file mode 100644 index b62b8e2..0000000 --- a/inc/3rdparty/PicoFarad/Router.php +++ /dev/null @@ -1,157 +0,0 @@ - 'value']); -function load() -{ - if (func_num_args() < 1 || func_num_args() > 2) { - die('Invalid template arguments'); - } - - if (! file_exists(PATH.func_get_arg(0).'.php')) { - die('Unable to load the template: "'.func_get_arg(0).'"'); - } - - if (func_num_args() === 2) { - - if (! is_array(func_get_arg(1))) { - die('Template variables must be an array'); - } - - extract(func_get_arg(1)); - } - - ob_start(); - include PATH.func_get_arg(0).'.php'; - return ob_get_clean(); -} - - -function layout($template_name, array $template_args = array(), $layout_name = 'layout') -{ - return load($layout_name, $template_args + array('content_for_layout' => load($template_name, $template_args))); -} diff --git a/inc/poche/Routing.class.php b/inc/poche/Routing.class.php index 6e2c046..8c2f38e 100644 --- a/inc/poche/Routing.class.php +++ b/inc/poche/Routing.class.php @@ -11,8 +11,8 @@ class Routing { protected $wallabag; - public $referer; - public $view; + protected $referer; + protected $view; protected $action; protected $id; protected $url; @@ -55,7 +55,7 @@ class Routing # because messages can be added in $poche->action(), we have to add this entry now (we can add it before) $this->vars = array_merge($this->vars, array('messages' => $this->wallabag->messages->display('all', FALSE))); - $this->render($this->file, $this->vars); + $this->_render($this->file, $this->vars); } private function _defineTplInformation() @@ -142,7 +142,7 @@ class Routing } } - public function render($file, $vars) + public function _render($file, $vars) { echo $this->wallabag->tpl->render($file, $vars); } diff --git a/inc/poche/global.inc.php b/inc/poche/global.inc.php index 9d710b6..3eb64df 100755 --- a/inc/poche/global.inc.php +++ b/inc/poche/global.inc.php @@ -40,12 +40,6 @@ require_once INCLUDES . '/3rdparty/libraries/PHPePub/Logger.php'; require_once INCLUDES . '/3rdparty/libraries/PHPePub/EPub.php'; require_once INCLUDES . '/3rdparty/libraries/PHPePub/EPubChapterSplitter.php'; -require_once INCLUDES . '/3rdparty/PicoFarad/Request.php'; -require_once INCLUDES . '/3rdparty/PicoFarad/Response.php'; -require_once INCLUDES . '/3rdparty/PicoFarad/Router.php'; -require_once INCLUDES . '/3rdparty/PicoFarad/Session.php'; -require_once INCLUDES . '/3rdparty/PicoFarad/Template.php'; - # system configuration; database credentials et caetera require_once INCLUDES . '/poche/config.inc.php'; require_once INCLUDES . '/poche/config.inc.default.php'; @@ -61,10 +55,3 @@ if (!ini_get('date.timezone') || !@date_default_timezone_set(ini_get('date.timez if (defined('ERROR_REPORTING')) { error_reporting(ERROR_REPORTING); } - -// Start session -Session::$sessionName = 'wallabag'; -Session::init(); - -// Let's rock ! -$wallabag = new Poche(); diff --git a/index.php b/index.php index 6f19051..e199956 100755 --- a/index.php +++ b/index.php @@ -12,56 +12,9 @@ define ('POCHE', '1.8.0'); require 'check_setup.php'; require_once 'inc/poche/global.inc.php'; +// Start session +Session::$sessionName = 'wallabag'; +Session::init(); -use PicoFarad\Router; -use PicoFarad\Response; -use PicoFarad\Request; -use PicoFarad\Session; - -// Called before each action -Router\before(function($action) { - - // Open a session only for the specified directory - Session\open(dirname($_SERVER['PHP_SELF'])); - - // HTTP secure headers - Response\csp(); - Response\xframe(); - Response\xss(); - Response\nosniff(); -}); - -// Show help -Router\get_action('unread', function() use ($wallabag) { - $view = 'home'; - $id = 0; - - $tpl_vars = array( - 'referer' => $wallabag->routing->referer, - 'view' => $wallabag->routing->view, - 'poche_url' => Tools::getPocheUrl(), - 'title' => _('wallabag, a read it later open source system'), - 'token' => \Session::getToken(), - 'theme' => $wallabag->tpl->getTheme(), - 'entries' => '', - 'page_links' => '', - 'nb_results' => '', - 'listmode' => (isset($_COOKIE['listmode']) ? true : false), - ); - - $count = $wallabag->store->getEntriesByViewCount($view, $wallabag->user->getId(), $id); - - if ($count > 0) { - $wallabag->pagination->set_total($count); - $page_links = str_replace(array('previous', 'next'), array(_('previous'), _('next')), - $wallabag->pagination->page_links('?view=' . $view . '&sort=' . $_SESSION['sort'] . (($id)?'&id='.$id:'') . '&' )); - $tpl_vars['entries'] = $wallabag->store->getEntriesByView($view, $wallabag->user->getId(), $wallabag->pagination->get_limit(), $id); - $tpl_vars['page_links'] = $page_links; - $tpl_vars['nb_results'] = $count; - } - - $wallabag->routing->render('home.twig', $tpl_vars); - - Tools::logm('display ' . $view . ' view'); - -}); +// Let's rock ! +$wallabag = new Poche();