diff options
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -1084,7 +1084,8 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager, | |||
1084 | die(t('Wrong token.')); | 1084 | die(t('Wrong token.')); |
1085 | } | 1085 | } |
1086 | 1086 | ||
1087 | $alteredLinks = $LINKSDB->renameTag(escape($_POST['fromtag']), escape($_POST['totag'])); | 1087 | $toTag = isset($_POST['totag']) ? escape($_POST['totag']) : null; |
1088 | $alteredLinks = $LINKSDB->renameTag(escape($_POST['fromtag']), $toTag); | ||
1088 | $LINKSDB->save($conf->get('resource.page_cache')); | 1089 | $LINKSDB->save($conf->get('resource.page_cache')); |
1089 | foreach ($alteredLinks as $link) { | 1090 | foreach ($alteredLinks as $link) { |
1090 | $history->updateLink($link); | 1091 | $history->updateLink($link); |
@@ -1858,6 +1859,7 @@ $app->group('/api/v1', function() { | |||
1858 | })->add('\Shaarli\Api\ApiMiddleware'); | 1859 | })->add('\Shaarli\Api\ApiMiddleware'); |
1859 | 1860 | ||
1860 | $response = $app->run(true); | 1861 | $response = $app->run(true); |
1862 | |||
1861 | // Hack to make Slim and Shaarli router work together: | 1863 | // Hack to make Slim and Shaarli router work together: |
1862 | // If a Slim route isn't found and NOT API call, we call renderPage(). | 1864 | // If a Slim route isn't found and NOT API call, we call renderPage(). |
1863 | if ($response->getStatusCode() == 404 && strpos($_SERVER['REQUEST_URI'], '/api/v1') === false) { | 1865 | if ($response->getStatusCode() == 404 && strpos($_SERVER['REQUEST_URI'], '/api/v1') === false) { |
@@ -1865,5 +1867,12 @@ if ($response->getStatusCode() == 404 && strpos($_SERVER['REQUEST_URI'], '/api/v | |||
1865 | header('Content-Type: text/html; charset=utf-8'); | 1867 | header('Content-Type: text/html; charset=utf-8'); |
1866 | renderPage($conf, $pluginManager, $linkDb, $history, $sessionManager, $loginManager); | 1868 | renderPage($conf, $pluginManager, $linkDb, $history, $sessionManager, $loginManager); |
1867 | } else { | 1869 | } else { |
1870 | $response = $response | ||
1871 | ->withHeader('Access-Control-Allow-Origin', '*') | ||
1872 | ->withHeader( | ||
1873 | 'Access-Control-Allow-Headers', | ||
1874 | 'X-Requested-With, Content-Type, Accept, Origin, Authorization' | ||
1875 | ) | ||
1876 | ->withHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS'); | ||
1868 | $app->respond($response); | 1877 | $app->respond($response); |
1869 | } | 1878 | } |