]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Merge pull request #479 from ArthurHoaro/pluginsadmin-error-url
authorArthur <arthur@hoa.ro>
Mon, 15 Feb 2016 19:38:31 +0000 (20:38 +0100)
committerArthur <arthur@hoa.ro>
Mon, 15 Feb 2016 19:38:31 +0000 (20:38 +0100)
Fixes typo in plugin admin redirection URL

1  2 
index.php

diff --combined index.php
index 5de60425c4c8bdadecdad5163918a5491c24d16c,67290f6fe9b68f0f20254e5315949ba6a4a786e0..4382bd808ff9f035c681b9232a6a76b348bea4cd
+++ b/index.php
@@@ -44,9 -44,6 +44,9 @@@ $GLOBALS['config']['DATASTORE'] = $GLOB
  // Banned IPs
  $GLOBALS['config']['IPBANS_FILENAME'] = $GLOBALS['config']['DATADIR'].'/ipbans.php';
  
 +// Processed updates file.
 +$GLOBALS['config']['UPDATES_FILE'] = $GLOBALS['config']['DATADIR'].'/updates.txt';
 +
  // Access log
  $GLOBALS['config']['LOG_FILE'] = $GLOBALS['config']['DATADIR'].'/log.txt';
  
@@@ -67,6 -64,7 +67,6 @@@ $GLOBALS['config']['CACHEDIR'] = 'cache
  // Atom & RSS feed cache directory
  $GLOBALS['config']['PAGECACHE'] = 'pagecache';
  
 -
  /*
   * Global configuration
   */
@@@ -165,7 -163,6 +165,7 @@@ require_once 'application/Utils.php'
  require_once 'application/Config.php';
  require_once 'application/PluginManager.php';
  require_once 'application/Router.php';
 +require_once 'application/Updater.php';
  
  // Ensure the PHP version is supported
  try {
@@@ -1117,25 -1114,6 +1117,25 @@@ function renderPage(
          $GLOBALS['redirector']
      );
  
 +    $updater = new Updater(
 +        read_updates_file($GLOBALS['config']['UPDATES_FILE']),
 +        $GLOBALS,
 +        $LINKSDB,
 +        isLoggedIn()
 +    );
 +    try {
 +        $newUpdates = $updater->update();
 +        if (! empty($newUpdates)) {
 +            write_updates_file(
 +                $GLOBALS['config']['UPDATES_FILE'],
 +                $updater->getDoneUpdates()
 +            );
 +        }
 +    }
 +    catch(Exception $e) {
 +        die($e->getMessage());
 +    }
 +
      $PAGE = new pageBuilder;
  
      // Determine which page will be rendered.
      // -------- User clicked the "Save" button when editing a link: Save link to database.
      if (isset($_POST['save_edit']))
      {
 -        if (!tokenOk($_POST['token'])) die('Wrong token.'); // Go away!
 -        $tags = trim(preg_replace('/\s\s+/',' ', $_POST['lf_tags'])); // Remove multiple spaces.
 -        $tags = implode(' ', array_unique(explode(' ', $tags))); // Remove duplicates.
 -        $linkdate=$_POST['lf_linkdate'];
 +        // Go away!
 +        if (! tokenOk($_POST['token'])) {
 +            die('Wrong token.');
 +        }
 +        // Remove multiple spaces.
 +        $tags = trim(preg_replace('/\s\s+/', ' ', $_POST['lf_tags']));
 +        // Remove duplicates.
 +        $tags = implode(' ', array_unique(explode(' ', $tags)));
 +        $linkdate = $_POST['lf_linkdate'];
          $url = trim($_POST['lf_url']);
 -        if (!startsWith($url,'http:') && !startsWith($url,'https:') && !startsWith($url,'ftp:') && !startsWith($url,'magnet:') && !startsWith($url,'?') && !startsWith($url,'javascript:'))
 -            $url = 'http://'.$url;
 -        $link = array('title'=>trim($_POST['lf_title']),'url'=>$url,'description'=>trim($_POST['lf_description']),'private'=>(isset($_POST['lf_private']) ? 1 : 0),
 -                      'linkdate'=>$linkdate,'tags'=>str_replace(',',' ',$tags));
 -        if ($link['title']=='') $link['title']=$link['url']; // If title is empty, use the URL as title.
 +        if (! startsWith($url, 'http:') && ! startsWith($url, 'https:')
 +            && ! startsWith($url, 'ftp:') && ! startsWith($url, 'magnet:')
 +            && ! startsWith($url, '?') && ! startsWith($url, 'javascript:')
 +        ) {
 +            $url = 'http://' . $url;
 +        }
 +
 +        $link = array(
 +            'title' => trim($_POST['lf_title']),
 +            'url' => $url,
 +            'description' => trim($_POST['lf_description']),
 +            'private' => (isset($_POST['lf_private']) ? 1 : 0),
 +            'linkdate' => $linkdate,
 +            'tags' => str_replace(',', ' ', $tags)
 +        );
 +        // If title is empty, use the URL as title.
 +        if ($link['title'] == '') {
 +            $link['title'] = $link['url'];
 +        }
  
          $pluginManager->executeHooks('save_link', $link);
  
          $LINKSDB[$linkdate] = $link;
 -        $LINKSDB->savedb($GLOBALS['config']['PAGECACHE']); // Save to disk.
 +        $LINKSDB->savedb($GLOBALS['config']['PAGECACHE']);
          pubsubhub();
  
          // If we are called from the bookmarklet, we must close the popup:
              exit;
          }
  
 -        $returnurl = !empty($_POST['returnurl']) ? escape($_POST['returnurl']): '?';
 +        $returnurl = !empty($_POST['returnurl']) ? $_POST['returnurl'] : '?';
          $location = generateLocation($returnurl, $_SERVER['HTTP_HOST'], array('addlink', 'post', 'edit_link'));
 -        $location .= '#'.smallHash($_POST['lf_linkdate']);  // Scroll to the link which has been edited.
 -        header('Location: '. $location); // After saving the link, redirect to the page the user was on.
 +        // Scroll to the link which has been edited.
 +        $location .= '#' . smallHash($_POST['lf_linkdate']);
 +        // After saving the link, redirect to the page the user was on.
 +        header('Location: '. $location);
          exit;
      }
  
@@@ -1858,7 -1815,7 +1858,7 @@@ HTML
              );
  
              // TODO: do not handle exceptions/errors in JS.
-             echo '<script>alert("'. $e->getMessage() .'");document.location=\'?do=pluginsadmin\';</script>';
+             echo '<script>alert("'. $e->getMessage() .'");document.location=\'?do='. Router::$PAGE_PLUGINSADMIN .'\';</script>';
              exit;
          }
          header('Location: ?do='. Router::$PAGE_PLUGINSADMIN);
@@@ -2562,6 -2519,15 +2562,6 @@@ function resizeImage($filepath
      return true;
  }
  
 -try {
 -    mergeDeprecatedConfig($GLOBALS, isLoggedIn());
 -} catch(Exception $e) {
 -    error_log(
 -        'ERROR while merging deprecated options.php file.' . PHP_EOL .
 -        $e->getMessage()
 -    );
 -}
 -
  if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=genthumbnail')) { genThumbnail(); exit; }  // Thumbnail generation/cache does not need the link database.
  if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=rss')) { showRSS(); exit; }
  if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=atom')) { showATOM(); exit; }