]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
Fix bug #2960663: do not send content-type headers twice for ajax/api scripts
authorcweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>
Wed, 17 Mar 2010 20:11:21 +0000 (20:11 +0000)
committercweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>
Wed, 17 Mar 2010 20:11:21 +0000 (20:11 +0000)
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@690 b3834d28-1941-0410-a4f8-b48e95affb8f

27 files changed:
src/SemanticScuttle/header.php
www/ajax/getadminlinkedtags.php
www/ajax/getadmintags.php
www/ajax/getcontacttags.php
www/ajax/getlinkedtags.php
www/ajax/gettags.php
www/ajaxDelete.php
www/ajaxGetTitle.php
www/ajaxIsAvailable.php
www/ajaxVote.php
www/api/export_csv.php
www/api/export_gcs.php
www/api/export_sioc.php
www/api/opensearch.php
www/api/posts_add.php
www/api/posts_all.php
www/api/posts_dates.php
www/api/posts_delete.php
www/api/posts_get.php
www/api/posts_public.php
www/api/posts_recent.php
www/api/posts_update.php
www/api/tags_get.php
www/api/tags_rename.php
www/go.php
www/jsScuttle.php
www/rss.php

index 12c1f720440a390ce9aff1de9159ee6e5b2714a5..ef36e83d39f1d4036d55f8e4e56dac5eb88e7cb2 100644 (file)
@@ -107,6 +107,12 @@ $tplVars['userservice'] = $userservice;
 
 // 6 // Force UTF-8 behaviour for server (cannot be moved into top.inc.php which is not included into every file)
 if (!defined('UNIT_TEST_MODE')) {
-    header('Content-Type: text/html; charset=utf-8');
+    //API files define that, so we need a way to support both of them
+    if (!isset($httpContentType)) {
+        $httpContentType = 'text/html';
+    }
+    if ($httpContentType !== false) {
+        header('Content-Type: ' . $httpContentType . '; charset=utf-8');
+    }
 }
 ?>
index 6abc06762209e0423e0b0705fa0ba5e63ad8ae7b..6646c50560c4d62ce86d3e649fd1386d3de8c99f 100644 (file)
@@ -20,7 +20,7 @@
  ***************************************************************************/
 
 /* Return a json file with list of linked tags */
-
+$httpContentType = 'application/json';
 require_once '../www-header.php';
 
 /* Service creation: only useful services are created */
index db62fc77608fbbf388f26311ccecb15b0b100202..ffd20bbfcbeb8af533f71c6fab02c0fa4764dbba 100644 (file)
@@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 ***************************************************************************/
 
 /* Return a json file with list of tags according to current user and sort by popularity*/
-
+$httpContentType = 'application/json';
 require_once '../www-header.php';
 
 /* Service creation: only useful services are created */
index 85ef1aedac9fab426b97469edcf191f014ffbaa7..89d6a3a523f26c2bdfba3590ab42b36a412c0ffa 100644 (file)
@@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 ***************************************************************************/
 
 /* Return a json file with list of tags according to current user and sort by popularity*/
-
+$httpContentType = 'application/json';
 require_once '../www-header.php';
 
 /* Service creation: only useful services are created */
index 6de272b2c3fab86071002725a02b9012c9ad05dc..f412998d9ffcb7116ab040793c2583390bfb27d6 100644 (file)
@@ -20,7 +20,7 @@
  ***************************************************************************/
 
 /* Return a json file with list of linked tags */
-
+$httpContentType = 'application/json';
 require_once '../www-header.php';
 
 /* Service creation: only useful services are created */
index 3672832a9d532328cfc88c2fff936d81dfd40611..cb73720226391395395f48d67f5d123a4d85522a 100644 (file)
@@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 ***************************************************************************/
 
 /* Return a json file with list of tags according to current user and sort by popularity*/
-
+$httpContentType = 'application/json';
 require_once '../www-header.php';
 
 /* Service creation: only useful services are created */
index 467e20e974f727a49fe88bba88cb88576aa1b7c9..281261217e5eb2ba477b891dc0297a9c3505c55e 100644 (file)
@@ -19,9 +19,9 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 ***************************************************************************/
 
-header('Content-Type: text/xml; charset=UTF-8');
 header('Last-Modified: '. gmdate("D, d M Y H:i:s") .' GMT');
 header('Cache-Control: no-cache, must-revalidate');
+$httpContentType = 'text/xml';
 require_once 'www-header.php';
 
 /* Service creation: only useful services are created */
index 6caa742e6e8c6da784242a38839c2a21e287bee9..b4f44ca0da68440a6b96e38597e93c94d7fe761c 100644 (file)
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  ***************************************************************************/
 
-header('Content-Type: text/xml; charset=UTF-8');
 header("Last-Modified: ". gmdate("D, d M Y H:i:s") ." GMT");
 header("Cache-Control: no-cache, must-revalidate");
 
+$httpContentType = 'text/xml';
 require_once 'www-header.php';
 
 /* Managing all possible inputs */
index 339056959a701db93530a7e5e98e4a7bf3e0caca..41e825e6c387e4c1918e9f7f0cc141f9c7103221 100644 (file)
@@ -19,10 +19,10 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 ***************************************************************************/
 
-header('Content-Type: text/xml; charset=UTF-8');
 header("Last-Modified: ". gmdate("D, d M Y H:i:s") ." GMT");
 header("Cache-Control: no-cache, must-revalidate");
 
+$httpContentType = 'text/xml';
 require_once 'www-header.php';
 
 /* Service creation: only useful services are created */
index 3e603daf721b49d5240c10cee388948589496d22..f2572fbd7e79e2cb351b111fff284128c743e0fb 100644 (file)
@@ -2,6 +2,7 @@
 /**
  * We re-use vote.php but set the ajax flag
  */
+$httpContentType = 'text/xml';
 $GLOBALS['ajaxRequest'] = true;
 require 'vote.php';
 
@@ -17,7 +18,6 @@ default:
     $template = 'bookmarks-vote.inc.tpl.php';
 }
 
-header('Content-Type: text/xml; charset=utf-8');
 echo '<voteresult><bookmark>' . $bookmark . '</bookmark>'
     . '<html xmlns="http://www.w3.org/1999/xhtml">';
 $ts->loadTemplate(
index 3f63692884b91864a3f9da593e1457f9e2e630b6..b9cf497baf87710d93165be91401e4bf6517e961 100644 (file)
@@ -2,8 +2,9 @@
 // Export in CSV format in order to allow the import into a spreadsheet tool like Excel
 
 // Force HTTP authentication first!
-require_once('httpauth.inc.php');
-require_once '../www-header.php';
+$httpContentType = 'application/csv-tab-delimited-table';
+require_once 'httpauth.inc.php';
+header("Content-disposition: filename=exportBookmarks.csv");
 
 /* Service creation: only useful services are created */
 $bookmarkservice =SemanticScuttle_Service_Factory::get('Bookmark');
@@ -17,9 +18,6 @@ else
 // Get the posts relevant to the passed-in variables.
 $bookmarks =& $bookmarkservice->getBookmarks(0, NULL, $userservice->getCurrentUserId(), $tag, NULL, getSortOrder());
 
-header("Content-Type: application/csv-tab-delimited-table;charset=UTF-8");
-header("Content-disposition: filename=exportBookmarks.csv");
-
 //columns titles
 echo 'url;title;tags;description';
 echo "\n";
index 07bc726293ebdcf09880d1492e11b899eaa60360..9c0d85c92040323cf55d25ea29222a525f4dd531 100644 (file)
@@ -5,6 +5,7 @@
 
 // Force HTTP authentication first!
 //require_once('httpauth.inc.php');
+$httpContentType = false;
 require_once '../www-header.php';
 
 if($GLOBALS['enableGoogleCustomSearch'] == false) {
@@ -39,7 +40,7 @@ $bookmarks =& $bookmarkservice->getBookmarks(0, NULL, NULL, $tag, NULL, getSortO
 
 
 // Set up the plain file and output all the posts.
-header('Content-Type: text/plain');
+header('Content-Type: text/plain; charset=utf-8');
 if(!$xml) {
        header('Content-Type: text/plain');
        foreach($bookmarks['bookmarks'] as $row) {
@@ -48,7 +49,7 @@ if(!$xml) {
                }
        }
 } else {
-       header('Content-Type: application/xml');
+       header('Content-Type: text/xml');
        echo '<GoogleCustomizations>'."\n";
        echo '  <Annotations>'."\n";
        foreach($bookmarks['bookmarks'] as $row) {
index ff1d1c0b549b345621a374b50be0c2bc03e72dbb..8bdfd707bd60a6ff2258f2915f6d2f610e60aa73 100644 (file)
@@ -1,8 +1,8 @@
 <?php
 /* Export data with semantic format (SIOC: http://sioc-project.org/, FOAF, SKOS, Annotea Ontology) */
 
+$httpContentType = 'text/xml';
 require_once '../www-header.php';
-header('Content-Type: text/xml; charset=utf-8'); //we change headers html defined in headers.inc.php
 
 /* Service creation: only useful services are created */
 $userservice =SemanticScuttle_Service_Factory::get('User');
index 68d094cc43259af100a85178ac5c2d219280b9d3..db95639d24d1a4db7901289a2118308d290cc13a 100644 (file)
@@ -1,6 +1,6 @@
 <?php 
+$httpContentType = 'text/xml';
 require_once '../www-header.php';
-header("Content-type: text/xml");
 ?>
 <?xml version="1.0" encoding="utf-8" ?>
 <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
index c919ee7219f75c8e96ba1f608b0207af14831044..59f7dce026f53a82cafffecc26056c251b10340b 100644 (file)
@@ -11,8 +11,8 @@
 // - No support for 'replace' variable
 
 // Force HTTP authentication
-require_once('httpauth.inc.php');
-require_once '../www-header.php';
+$httpContentType = 'text/xml';
+require_once 'httpauth.inc.php';
 
 /* Service creation: only useful services are created */
 $bookmarkservice =SemanticScuttle_Service_Factory::get('Bookmark');
@@ -82,7 +82,6 @@ if (is_null($url) || is_null($description)) {
 }
 
 // Set up the XML file and output the result.
-header('Content-Type: text/xml');
 echo '<?xml version="1.0" standalone="yes" ?'.">\r\n";
 echo '<result code="'. ($added ? 'done' : 'something went wrong') .'" />';
 ?>
\ No newline at end of file
index f53f363f3ab55afbc90493a2610c4ef905c031a1..2d274f48a9cc7e3afedc3af3294b5661275f20db 100644 (file)
@@ -5,8 +5,8 @@
 // - doesn't include the filtered tag as an attribute on the root element (we do)
 
 // Force HTTP authentication first!
-require_once('httpauth.inc.php');
-require_once '../www-header.php';
+$httpContentType = 'text/xml';
+require_once 'httpauth.inc.php';
 
 /* Service creation: only useful services are created */
 $bookmarkservice =SemanticScuttle_Service_Factory::get('Bookmark');
@@ -22,7 +22,6 @@ else
 $bookmarks =& $bookmarkservice->getBookmarks(0, NULL, $userservice->getCurrentUserId(), $tag);
 
 // Set up the XML file and output all the posts.
-header('Content-Type: text/xml');
 echo '<?xml version="1.0" standalone="yes" ?'.">\r\n";
 echo '<posts update="'. gmdate('Y-m-d\TH:i:s\Z') .'" user="'. htmlspecialchars($currentUser->getUsername()) .'"'. (is_null($tag) ? '' : ' tag="'. htmlspecialchars($tag) .'"') .">\r\n";
 
index 7b1240f48d9bf2f4bd4f62c0e3ce417fb1142437..508c46af5d77f0746d653fd94fd7f80006f20e43 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 // Force HTTP authentication first!
+$httpContentType = 'text/xml';
 require_once 'httpauth.inc.php';
 
 /* Service creation: only useful services are created */
@@ -36,7 +37,6 @@ $bookmarks = $bookmarkservice->getBookmarks(
 );
 
 //     Set up the XML file and output all the tags.
-header('Content-Type: text/xml');
 echo '<?xml version="1.0" standalone="yes" ?'.">\r\n";
 echo '<dates tag="'. (is_null($tag) ? '' : filter($tag, 'xml')) .'" user="'. filter($currentUser->getUsername(), 'xml') ."\">\r\n";
 
index 88e25841f1763674ddd481d86fb13477ffbde7b5..a63cc62485ee0884e73d44fd4d42336a928ad000 100644 (file)
@@ -7,8 +7,8 @@
 // - doesn't set the Content-Type to text/xml (we do).
 
 // Force HTTP authentication first!
-require_once('httpauth.inc.php');
-require_once '../www-header.php';
+$httpContentType = 'text/xml';
+require_once 'httpauth.inc.php';
 
 /* Service creation: only useful services are created */
 $bookmarkservice =SemanticScuttle_Service_Factory::get('Bookmark');
@@ -28,7 +28,6 @@ if (is_null($_REQUEST['url'])) {
 }
 
 // Set up the XML file and output the result.
-header('Content-Type: text/xml');
 echo '<?xml version="1.0" standalone="yes" ?'.">\r\n";
 echo '<result code="'. ($deleted ? 'done' : 'something went wrong') .'" />';
 ?>
\ No newline at end of file
index b020f51e6ff1d99a00687c7c79758039fa6393b6..c20f904ac30907e2b300f905374d1a982f52abc3 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 // Force HTTP authentication first!
+$httpContentType = 'text/xml';
 require_once 'httpauth.inc.php';
 
 /* Service creation: only useful services are created */
@@ -54,7 +55,6 @@ $bookmarks = $bookmarkservice->getBookmarks(
 
 
 // Set up the XML file and output all the tags.
-header('Content-Type: text/xml');
 echo '<?xml version="1.0" standalone="yes" ?'.">\r\n";
 echo '<posts'. (is_null($dtstart) ? '' : ' dt="'. $dtstart .'"') .' tag="'. (is_null($tag) ? '' : filter($tag, 'xml')) .'" user="'. filter($currentUser->getUsername(), 'xml') ."\">\r\n";
 
index 0c93ca22d23dd04117ca5edc300eeacabffe3049..42585500e1e8fb9392a7a1b20e8d4aac869e738a 100644 (file)
@@ -6,6 +6,7 @@
 
 // Force HTTP authentication first!
 //require_once('httpauth.inc.php');
+$httpContentType = 'text/xml';
 require_once '../www-header.php';
 
 /* Service creation: only useful services are created */
@@ -22,7 +23,6 @@ else
 $bookmarks =& $bookmarkservice->getBookmarks(0, NULL, NULL, $tag);
 
 // Set up the XML file and output all the posts.
-header('Content-Type: text/xml');
 echo '<?xml version="1.0" standalone="yes" ?'.">\r\n";
 echo '<posts update="'. gmdate('Y-m-d\TH:i:s\Z') .'" '. (is_null($tag) ? '' : ' tag="'. htmlspecialchars($tag) .'"') .">\r\n";
 
index 46e46f1145a5273e99babde06843accb8b54de74..6c71e226e074ca4dc1a1d7922a07dba5f2513843 100644 (file)
@@ -22,6 +22,7 @@ $countDefault = 15;
 $countMax     = 100;
 
 // Force HTTP authentication first!
+$httpContentType = 'text/xml';
 require_once 'httpauth.inc.php';
 
 /* Service creation: only useful services are created */
@@ -54,7 +55,6 @@ $bookmarks = $bookmarkservice->getBookmarks(
 
 
 // Set up the XML file and output all the tags.
-header('Content-Type: text/xml');
 echo '<?xml version="1.0" standalone="yes" ?'.">\r\n";
 echo '<posts tag="'. (is_null($tag) ? '' : filter($tag, 'xml')) .'" user="'. filter($currentUser->getUsername(), 'xml') ."\">\r\n";
 
index 9152f269a5c17db773f62e210517a5be76030950..4aeedc369e2f2fa82897bbcec909ed92b3cac279 100644 (file)
@@ -5,8 +5,8 @@
 // - doesn't set the Content-Type to text/xml (we do).
 
 // Force HTTP authentication first!
-require_once('httpauth.inc.php');
-require_once '../www-header.php';
+$httpContentType = 'text/xml';
+require_once 'httpauth.inc.php';
 
 /* Service creation: only useful services are created */
 $bookmarkservice =SemanticScuttle_Service_Factory::get('Bookmark');
@@ -17,7 +17,6 @@ $bookmarks =& $bookmarkservice->getBookmarks(0, 1, $userservice->getCurrentUserI
 
 
 // Set up the XML file and output all the tags.
-header('Content-Type: text/xml');
 echo '<?xml version="1.0" standalone="yes" ?'.">\r\n";
 foreach($bookmarks['bookmarks'] as $row) {
     echo '<update time="'. gmdate('Y-m-d\TH:i:s\Z', strtotime($row['bDatetime'])) .'" />';
index 85684d43ce0fa8dd9e578100a7cd6ede18d1f133..06a40d90d9636a4cbefc0b00354589af97cde17e 100644 (file)
@@ -5,8 +5,8 @@
 // - tags can't have spaces
 
 // Force HTTP authentication first!
-require_once('httpauth.inc.php');
-require_once '../www-header.php';
+$httpContentType = 'text/xml';
+require_once 'httpauth.inc.php';
 
 /* Service creation: only useful services are created */
 $b2tservice =SemanticScuttle_Service_Factory::get('Bookmark2Tag');
@@ -16,7 +16,6 @@ $b2tservice =SemanticScuttle_Service_Factory::get('Bookmark2Tag');
 $tags =& $b2tservice->getTags($userservice->getCurrentUserId());
 
 // Set up the XML file and output all the tags.
-header('Content-Type: text/xml');
 echo '<?xml version="1.0" standalone="yes" ?'.">\r\n";
 echo "<tags>\r\n";
 foreach($tags as $row) {
index 59ba8a4c83529a529a58fe44e191c02c8e032ca5..cf56c83012cc1c7912d17edbb6016162bddcc5e3 100644 (file)
@@ -5,8 +5,8 @@
 // - oddly, returns an entirely different result (<result></result>) than the other API calls.
 
 // Force HTTP authentication first!
-require_once('httpauth.inc.php');
-require_once '../www-header.php';
+$httpContentType = 'text/xml';
+require_once 'httpauth.inc.php';
 
 /* Service creation: only useful services are created */
 $b2tservice =SemanticScuttle_Service_Factory::get('Bookmark2Tag');
@@ -31,7 +31,6 @@ if (is_null($old) || is_null($new)) {
 }
 
 // Set up the XML file and output the result.
-header('Content-Type: text/xml');
 echo '<?xml version="1.0" standalone="yes" ?'.">\r\n";
 echo '<result>'. ($renamed ? 'done' : 'something went wrong') .'</result>';
 ?>
index 3d271c449e5d96cebc2cc4051a30c92731bcf86f..6a36ba9ec232933a06a08d90988c9268df5abaf9 100644 (file)
@@ -15,6 +15,7 @@
  * @license  GPL http://www.gnu.org/licenses/gpl.html
  * @link     http://sourceforge.net/projects/semanticscuttle
  */
+$httpContentType = false;
 require_once 'www-header.php';
 
 if (!$GLOBALS['shorturl']) {
index cc4e16d5e1d3ea86dc086ac0ed9468f5b0589933..f37da786fff6edca5fb726dcfb83597efa9b3871 100644 (file)
@@ -1,6 +1,6 @@
 <?php
-header('Content-Type: text/javascript');
 $GLOBALS['saveInLastUrl'] = false;
+$httpContentType = 'text/javascript';
 require_once 'www-header.php';
 require_once 'SemanticScuttle/functions.php';
 $player_root = ROOT .'includes/player/';
index 7f706d557f26bba285c36fdc17330b1d0a32de7a..6dcfb4c85a34aedf5f9e5b8871595ae6c60b2011 100644 (file)
  * @link     http://sourceforge.net/projects/semanticscuttle
  */
 
+$httpContentType = 'application/rss+xml';
 require_once 'www-header.php';
 
 /* Service creation: only useful services are created */
 $bookmarkservice = SemanticScuttle_Service_Factory::get('Bookmark');
 $cacheservice    = SemanticScuttle_Service_Factory::get('Cache');
 
-header('Content-Type: application/rss+xml; charset=utf-8');
-
 if (isset($_SERVER['PATH_INFO']) && strlen($_SERVER['PATH_INFO']) >1) {
     list($url, $user, $cat) = explode('/', $_SERVER['PATH_INFO']);
 } else {