X-Git-Url: https://git.immae.eu/?p=github%2Fshaarli%2FShaarli.git;a=blobdiff_plain;f=index.php;h=66fe30f1921ed3fdb842c275c85d04e42cf4a74c;hp=2e350fcf915bdd0b4a2d194e8d8794be64ca0783;hb=51753e403fa69c0ce124ede27d300477e3e799ca;hpb=93bf0918fa7bb1efb39d1540d7e46e52767270df diff --git a/index.php b/index.php index 2e350fcf..66fe30f1 100644 --- a/index.php +++ b/index.php @@ -57,25 +57,26 @@ require_once __DIR__ . '/vendor/autoload.php'; // Shaarli library require_once 'application/ApplicationUtils.php'; -require_once 'application/Cache.php'; -require_once 'application/CachedPage.php'; require_once 'application/config/ConfigPlugin.php'; -require_once 'application/FeedBuilder.php'; +require_once 'application/feed/Cache.php'; +require_once 'application/http/HttpUtils.php'; +require_once 'application/http/UrlUtils.php'; require_once 'application/FileUtils.php'; require_once 'application/History.php'; -require_once 'application/HttpUtils.php'; require_once 'application/LinkDB.php'; require_once 'application/LinkFilter.php'; require_once 'application/LinkUtils.php'; require_once 'application/NetscapeBookmarkUtils.php'; require_once 'application/PageBuilder.php'; require_once 'application/TimeZone.php'; -require_once 'application/Url.php'; require_once 'application/Utils.php'; require_once 'application/PluginManager.php'; require_once 'application/Router.php'; require_once 'application/Updater.php'; use \Shaarli\Config\ConfigManager; +use \Shaarli\Feed\CachedPage; +use \Shaarli\Feed\FeedBuilder; +use \Shaarli\History; use \Shaarli\Languages; use \Shaarli\Security\LoginManager; use \Shaarli\Security\SessionManager; @@ -806,7 +807,10 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager, $params['searchtags'] = trim($params['searchtags']).' '.trim($_GET['addtag']); } - unset($params['page']); // We also remove page (keeping the same page has no sense, since the results are different) + // We also remove page (keeping the same page has no sense, since the + // results are different) + unset($params['page']); + header('Location: ?'.http_build_query($params)); exit; } @@ -837,7 +841,9 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager, unset($params['searchtags']); } - unset($params['page']); // We also remove page (keeping the same page has no sense, since the results are different) + // We also remove page (keeping the same page has no sense, since + // the results are different) + unset($params['page']); } header('Location: ?'.http_build_query($params)); exit; @@ -954,15 +960,26 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager, } // Make sure old password is correct. - $oldhash = sha1($_POST['oldpassword'].$conf->get('credentials.login').$conf->get('credentials.salt')); - if ($oldhash!= $conf->get('credentials.hash')) { - echo ''; + $oldhash = sha1( + $_POST['oldpassword'].$conf->get('credentials.login').$conf->get('credentials.salt') + ); + if ($oldhash != $conf->get('credentials.hash')) { + echo ''; exit; } // Save new password // Salt renders rainbow-tables attacks useless. $conf->set('credentials.salt', sha1(uniqid('', true) .'_'. mt_rand())); - $conf->set('credentials.hash', sha1($_POST['setpassword'] . $conf->get('credentials.login') . $conf->get('credentials.salt'))); + $conf->set( + 'credentials.hash', + sha1( + $_POST['setpassword'] + . $conf->get('credentials.login') + . $conf->get('credentials.salt') + ) + ); try { $conf->write($loginManager->isLoggedIn()); } catch (Exception $e) { @@ -1015,7 +1032,8 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager, && $thumbnailsMode !== $conf->get('thumbnails.mode', Thumbnailer::MODE_NONE) ) { $_SESSION['warnings'][] = t( - 'You have enabled or changed thumbnails mode. Please synchronize them.' + 'You have enabled or changed thumbnails mode. ' + .'Please synchronize them.' ); } $conf->set('thumbnails.mode', $thumbnailsMode); @@ -1296,7 +1314,9 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager, $description = empty($_GET['description']) ? '' : escape($_GET['description']); $tags = empty($_GET['tags']) ? '' : escape($_GET['tags']); $private = !empty($_GET['private']) && $_GET['private'] === "1" ? 1 : 0; - // If this is an HTTP(S) link, we try go get the page to extract the title (otherwise we will to straight to the edit form.) + + // If this is an HTTP(S) link, we try go get the page to extract + // the title (otherwise we will to straight to the edit form.) if (empty($title) && strpos(get_url_scheme($url), 'http') !== false) { // Short timeout to keep the application responsive // The callback will fill $charset and $title with data from the downloaded page. @@ -1514,7 +1534,11 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager, ); // TODO: do not handle exceptions/errors in JS. - echo ''; + echo ''; exit; } header('Location: ?do='. Router::$PAGE_PLUGINSADMIN); @@ -1749,7 +1773,8 @@ function install($conf, $sessionManager, $loginManager) // This part makes sure sessions works correctly. // (Because on some hosts, session.save_path may not be set correctly, // or we may not have write access to it.) - if (isset($_GET['test_session']) && ( !isset($_SESSION) || !isset($_SESSION['session_tested']) || $_SESSION['session_tested']!='Working')) { + if (isset($_GET['test_session']) + && ( !isset($_SESSION) || !isset($_SESSION['session_tested']) || $_SESSION['session_tested']!='Working')) { // Step 2: Check if data in session is correct. $msg = t( '
Sessions do not seem to work correctly on your server.
'. @@ -1817,7 +1842,10 @@ function install($conf, $sessionManager, $loginManager) echo ''; exit; } - echo ''; + echo ''; exit; }