From d6889066c0d285bf59e89b484800443304585b68 Mon Sep 17 00:00:00 2001
From: mensonge
Date: Fri, 5 Dec 2008 07:25:04 +0000
Subject: Major Refactoring: finish transforming into object . Put and into
header.inc.php.
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@199 b3834d28-1941-0410-a4f8-b48e95affb8f
---
api/export_gcs.php | 5 ++---
api/export_html.php | 8 +++-----
api/httpauth.inc.php | 42 +++++++++++++++++++-----------------------
api/posts_add.php | 2 +-
api/posts_all.php | 8 +++-----
api/posts_dates.php | 8 +++-----
api/posts_delete.php | 3 ++-
api/posts_get.php | 7 +++----
api/posts_recent.php | 7 +++----
api/posts_update.php | 5 ++---
api/tags_get.php | 3 ++-
api/tags_rename.php | 2 +-
12 files changed, 44 insertions(+), 56 deletions(-)
(limited to 'api')
diff --git a/api/export_gcs.php b/api/export_gcs.php
index 1040dd4..6f1f4c2 100644
--- a/api/export_gcs.php
+++ b/api/export_gcs.php
@@ -12,8 +12,9 @@ if($GLOBALS['enableGoogleCustomSearch'] == false) {
die;
}
+/* Service creation: only useful services are created */
$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
-$userservice =& ServiceFactory::getServiceInstance('UserService');
+
/*
// Restrict to admins?
@@ -36,8 +37,6 @@ $tag = NULL;
// Get the posts relevant to the passed-in variables.
$bookmarks =& $bookmarkservice->getBookmarks(0, NULL, NULL, $tag, NULL, getSortOrder());
-$currentuser = $userservice->getCurrentUser();
-$currentusername = $currentuser[$userservice->getFieldName('username')];
// Set up the plain file and output all the posts.
header('Content-Type: text/plain');
diff --git a/api/export_html.php b/api/export_html.php
index b422b4b..79ade0a 100644
--- a/api/export_html.php
+++ b/api/export_html.php
@@ -7,9 +7,9 @@
// Force HTTP authentication first!
require_once('httpauth.inc.php');
require_once('../header.inc.php');
-
+
+/* Service creation: only useful services are created */
$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
-$userservice =& ServiceFactory::getServiceInstance('UserService');
// Check to see if a tag was specified.
if (isset($_REQUEST['tag']) && (trim($_REQUEST['tag']) != ''))
@@ -20,8 +20,6 @@ else
// Get the posts relevant to the passed-in variables.
$bookmarks =& $bookmarkservice->getBookmarks(0, NULL, $userservice->getCurrentUserId(), $tag, NULL, getSortOrder());
-$currentuser = $userservice->getCurrentUser();
-$currentusername = $currentuser[$userservice->getFieldName('username')];
// Set up the XML file and output all the posts.
header('Content-Type: text/html');
@@ -29,7 +27,7 @@ echo ''."\r\n";
echo '';
echo ''."\r\n";
echo '
Bookmarks'."\r\n";
-echo 'Bookmarks for '. htmlspecialchars($currentusername) .''. (is_null($tag) ? '' : ' tag="'. htmlspecialchars($tag) .'"') ." from " . $sitename ."
\r\n";
+echo 'Bookmarks for '. htmlspecialchars($currentUser->getUsername()) .''. (is_null($tag) ? '' : ' tag="'. htmlspecialchars($tag) .'"') ." from " . $sitename ."
\r\n";
echo ''."\r\n";
diff --git a/api/httpauth.inc.php b/api/httpauth.inc.php
index d0198fd..5dd7444 100644
--- a/api/httpauth.inc.php
+++ b/api/httpauth.inc.php
@@ -1,37 +1,33 @@
isLoggedOn()) {
- /* Maybe we have caught authentication data in $_SERVER['REMOTE_USER']
- ( Inspired by http://www.yetanothercommunitysystem.com/article-321-regle-comment-utiliser-l-authentification-http-en-php-chez-ovh ) */
- if((!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW']))
- && preg_match('/Basic\s+(.*)$/i', $_SERVER['REMOTE_USER'], $matches)) {
- list($name, $password) = explode(':', base64_decode($matches[1]));
- $_SERVER['PHP_AUTH_USER'] = strip_tags($name);
- $_SERVER['PHP_AUTH_PW'] = strip_tags($password);
- }
-
- if (!isset($_SERVER['PHP_AUTH_USER'])) {
- authenticate();
- } else {
- require_once('../header.inc.php');
- $userservice =& ServiceFactory::getServiceInstance('UserService');
+ /* Maybe we have caught authentication data in $_SERVER['REMOTE_USER']
+ ( Inspired by http://www.yetanothercommunitysystem.com/article-321-regle-comment-utiliser-l-authentification-http-en-php-chez-ovh ) */
+ if((!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW']))
+ && preg_match('/Basic\s+(.*)$/i', $_SERVER['REMOTE_USER'], $matches)) {
+ list($name, $password) = explode(':', base64_decode($matches[1]));
+ $_SERVER['PHP_AUTH_USER'] = strip_tags($name);
+ $_SERVER['PHP_AUTH_PW'] = strip_tags($password);
+ }
- $login = $userservice->login($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
- if (!$login) {
- authenticate();
+ if (!isset($_SERVER['PHP_AUTH_USER'])) {
+ authenticate();
+ } else {
+ $login = $userservice->login($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
+ if (!$login) {
+ authenticate();
+ }
}
- }
}
?>
diff --git a/api/posts_add.php b/api/posts_add.php
index 77c3288..e27fc99 100644
--- a/api/posts_add.php
+++ b/api/posts_add.php
@@ -13,8 +13,8 @@
require_once('httpauth.inc.php');
require_once('../header.inc.php');
+/* Service creation: only useful services are created */
$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
-$userservice =& ServiceFactory::getServiceInstance('UserService');
// Get all the bookmark's passed-in information
if (isset($_REQUEST['url']) && (trim($_REQUEST['url']) != ''))
diff --git a/api/posts_all.php b/api/posts_all.php
index 03026c4..4ecbd7e 100644
--- a/api/posts_all.php
+++ b/api/posts_all.php
@@ -8,8 +8,9 @@
require_once('httpauth.inc.php');
require_once('../header.inc.php');
+/* Service creation: only useful services are created */
$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
-$userservice =& ServiceFactory::getServiceInstance('UserService');
+
// Check to see if a tag was specified.
if (isset($_REQUEST['tag']) && (trim($_REQUEST['tag']) != ''))
@@ -20,13 +21,10 @@ else
// Get the posts relevant to the passed-in variables.
$bookmarks =& $bookmarkservice->getBookmarks(0, NULL, $userservice->getCurrentUserId(), $tag);
-$currentuser = $userservice->getCurrentUser();
-$currentusername = $currentuser[$userservice->getFieldName('username')];
-
// Set up the XML file and output all the posts.
header('Content-Type: text/xml');
echo '\r\n";
-echo '\r\n";
+echo '\r\n";
foreach($bookmarks['bookmarks'] as $row) {
if (is_null($row['bDescription']) || (trim($row['bDescription']) == ''))
diff --git a/api/posts_dates.php b/api/posts_dates.php
index 7098756..d4962ff 100644
--- a/api/posts_dates.php
+++ b/api/posts_dates.php
@@ -6,8 +6,9 @@
require_once('httpauth.inc.php');
require_once('../header.inc.php');
+/* Service creation: only useful services are created */
$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
-$userservice =& ServiceFactory::getServiceInstance('UserService');
+
// Check to see if a tag was specified.
if (isset($_REQUEST['tag']) && (trim($_REQUEST['tag']) != ''))
@@ -18,13 +19,10 @@ else
// Get the posts relevant to the passed-in variables.
$bookmarks =& $bookmarkservice->getBookmarks(0, NULL, $userservice->getCurrentUserId(), $tag);
-$currentuser = $userservice->getCurrentUser();
-$currentusername = $currentuser[$userservice->getFieldName('username')];
-
// Set up the XML file and output all the tags.
header('Content-Type: text/xml');
echo '\r\n";
-echo '\r\n";
+echo '\r\n";
$lastdate = NULL;
foreach($bookmarks['bookmarks'] as $row) {
diff --git a/api/posts_delete.php b/api/posts_delete.php
index 737a4fb..d24ba59 100644
--- a/api/posts_delete.php
+++ b/api/posts_delete.php
@@ -10,8 +10,9 @@
require_once('httpauth.inc.php');
require_once('../header.inc.php');
+/* Service creation: only useful services are created */
$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
-$userservice =& ServiceFactory::getServiceInstance('UserService');
+
// Note that del.icio.us only errors out if no URL was passed in; there's no error on attempting
// to delete a bookmark you don't have.
diff --git a/api/posts_get.php b/api/posts_get.php
index 8be067b..34d192e 100644
--- a/api/posts_get.php
+++ b/api/posts_get.php
@@ -13,8 +13,9 @@
require_once('httpauth.inc.php');
require_once('../header.inc.php');
+/* Service creation: only useful services are created */
$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
-$userservice =& ServiceFactory::getServiceInstance('UserService');
+
// Check to see if a tag was specified.
if (isset($_REQUEST['tag']) && (trim($_REQUEST['tag']) != ''))
@@ -32,13 +33,11 @@ $dtend = date('Y-m-d H:i:s', strtotime($dtstart .'+1 day'));
// Get the posts relevant to the passed-in variables.
$bookmarks =& $bookmarkservice->getBookmarks(0, NULL, $userservice->getCurrentUserId(), $tag, NULL, NULL, NULL, $dtstart, $dtend);
-$currentuser = $userservice->getCurrentUser();
-$currentusername = $currentuser[$userservice->getFieldName('username')];
// Set up the XML file and output all the tags.
header('Content-Type: text/xml');
echo '\r\n";
-echo '\r\n";
+echo '\r\n";
foreach($bookmarks['bookmarks'] as $row) {
if (is_null($row['bDescription']) || (trim($row['bDescription']) == ''))
diff --git a/api/posts_recent.php b/api/posts_recent.php
index 22fc2bd..daa9d39 100644
--- a/api/posts_recent.php
+++ b/api/posts_recent.php
@@ -10,8 +10,9 @@ $countMax = 100;
require_once('httpauth.inc.php');
require_once('../header.inc.php');
+/* Service creation: only useful services are created */
$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
-$userservice =& ServiceFactory::getServiceInstance('UserService');
+
// Check to see if a tag was specified.
if (isset($_REQUEST['tag']) && (trim($_REQUEST['tag']) != ''))
@@ -33,13 +34,11 @@ if (isset($_REQUEST['count']) && (intval($_REQUEST['count']) != 0)) {
// Get the posts relevant to the passed-in variables.
$bookmarks =& $bookmarkservice->getBookmarks(0, $count, $userservice->getCurrentUserId(), $tag);
-$currentuser = $userservice->getCurrentUser();
-$currentusername = $currentuser[$userservice->getFieldName('username')];
// Set up the XML file and output all the tags.
header('Content-Type: text/xml');
echo '\r\n";
-echo '\r\n";
+echo '\r\n";
foreach($bookmarks['bookmarks'] as $row) {
if (is_null($row['bDescription']) || (trim($row['bDescription']) == ''))
diff --git a/api/posts_update.php b/api/posts_update.php
index de379d2..6ea50e2 100644
--- a/api/posts_update.php
+++ b/api/posts_update.php
@@ -8,14 +8,13 @@
require_once('httpauth.inc.php');
require_once('../header.inc.php');
+/* Service creation: only useful services are created */
$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
-$userservice =& ServiceFactory::getServiceInstance('UserService');
+
// Get the posts relevant to the passed-in variables.
$bookmarks =& $bookmarkservice->getBookmarks(0, 1, $userservice->getCurrentUserId());
-$currentuser = $userservice->getCurrentUser();
-$currentusername = $currentuser[$userservice->getFieldName('username')];
// Set up the XML file and output all the tags.
header('Content-Type: text/xml');
diff --git a/api/tags_get.php b/api/tags_get.php
index 172dd0a..cee36ee 100644
--- a/api/tags_get.php
+++ b/api/tags_get.php
@@ -8,8 +8,9 @@
require_once('httpauth.inc.php');
require_once('../header.inc.php');
+/* Service creation: only useful services are created */
$b2tservice =& ServiceFactory::getServiceInstance('Bookmark2TagService');
-$userservice =& ServiceFactory::getServiceInstance('UserService');
+
// Get the tags relevant to the passed-in variables.
$tags =& $b2tservice->getTags($userservice->getCurrentUserId());
diff --git a/api/tags_rename.php b/api/tags_rename.php
index fc4f2ad..dd16339 100644
--- a/api/tags_rename.php
+++ b/api/tags_rename.php
@@ -8,8 +8,8 @@
require_once('httpauth.inc.php');
require_once('../header.inc.php');
+/* Service creation: only useful services are created */
$b2tservice =& ServiceFactory::getServiceInstance('Bookmark2TagService');
-$userservice =& ServiceFactory::getServiceInstance('UserService');
// Get the tag info.
if (isset($_REQUEST['old']) && (trim($_REQUEST['old']) != ''))
--
cgit v1.2.3-54-g00ecf