[geeklog-cvs] Geeklog-1.x/system lib-webservices.php,1.16,1.17
Dirk Haun
dhaun at qs1489.pair.com
Sun Nov 18 04:28:34 EST 2007
Update of /cvsroot/geeklog/Geeklog-1.x/system
In directory qs1489.pair.com:/tmp/cvs-serv40603
Modified Files:
lib-webservices.php
Log Message:
Added verbose logging option ($WS_VERBOSE)
Index: lib-webservices.php
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/system/lib-webservices.php,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** lib-webservices.php 4 Nov 2007 19:37:07 -0000 1.16
--- lib-webservices.php 18 Nov 2007 09:28:31 -0000 1.17
***************
*** 43,46 ****
--- 43,49 ----
$WS_EXTN_NS = 'http://www.geeklog.net';
+ // Set = true to enable verbose logging (in error.log)
+ $WS_VERBOSE = false;
+
if (!isset($WS_DISABLED)) {
$WS_DISABLED = false;
***************
*** 60,63 ****
--- 63,68 ----
function WS_error($error_code, $error_desc = '')
{
+ global $WS_VERBOSE;
+
header('Content-type: ' . 'text/html' . '; charset=UTF-8');
switch ($error_code) {
***************
*** 77,80 ****
--- 82,89 ----
}
+ if ($WS_VERBOSE) {
+ COM_errorLog("WS: Error $error_code ('$error_desc')");
+ }
+
// Output exact error message here
echo trim($error_desc);
***************
*** 89,97 ****
function WS_dissectURI(&$args)
{
! global $WS_PLUGIN, $WS_INTROSPECTION;
$WS_PLUGIN = '';
$args = array();
$uri_parts = explode('&', $_SERVER['QUERY_STRING']);
foreach ($uri_parts as $param) {
--- 98,110 ----
function WS_dissectURI(&$args)
{
! global $WS_PLUGIN, $WS_INTROSPECTION, $WS_VERBOSE;
$WS_PLUGIN = '';
$args = array();
+ if ($WS_VERBOSE) {
+ COM_errorLog("WS: Dissecting URI '" . $_SERVER['QUERY_STRING'] . "'");
+ }
+
$uri_parts = explode('&', $_SERVER['QUERY_STRING']);
foreach ($uri_parts as $param) {
***************
*** 124,128 ****
function WS_post()
{
! global $WS_PLUGIN, $WS_ATOM_NS, $WS_APP_NS, $WS_EXTN_NS, $_CONF;
WS_dissectURI($args);
--- 137,146 ----
function WS_post()
{
! global $WS_PLUGIN, $WS_ATOM_NS, $WS_APP_NS, $WS_EXTN_NS, $WS_VERBOSE,
! $_CONF;
!
! if ($WS_VERBOSE) {
! COM_errorLog("WS: POST request received");
! }
WS_dissectURI($args);
***************
*** 161,165 ****
function WS_put()
{
! global $WS_PLUGIN, $WS_ATOM_NS, $WS_APP_NS, $WS_EXTN_NS, $_CONF;
WS_dissectURI($args);
--- 179,188 ----
function WS_put()
{
! global $WS_PLUGIN, $WS_ATOM_NS, $WS_APP_NS, $WS_EXTN_NS, $WS_VERBOSE,
! $_CONF;
!
! if ($WS_VERBOSE) {
! COM_errorLog("WS: PUT request received");
! }
WS_dissectURI($args);
***************
*** 183,187 ****
WS_error($ret, $svc_msg['error_desc']);
-
}
--- 206,209 ----
***************
*** 191,195 ****
function WS_get()
{
! global $WS_PLUGIN, $WS_INTROSPECTION, $WS_ATOM_NS, $WS_APP_NS, $WS_EXTN_NS, $_CONF;
WS_dissectURI($args);
--- 213,222 ----
function WS_get()
{
! global $WS_PLUGIN, $WS_INTROSPECTION, $WS_ATOM_NS, $WS_APP_NS, $WS_EXTN_NS,
! $WS_VERBOSE, $_CONF;
!
! if ($WS_VERBOSE) {
! COM_errorLog("WS: GET request received");
! }
WS_dissectURI($args);
***************
*** 335,339 ****
function WS_delete()
{
! global $WS_PLUGIN, $WS_ATOM_NS, $WS_APP_NS, $WS_EXTN_NS, $_CONF;
WS_dissectURI($args);
--- 362,371 ----
function WS_delete()
{
! global $WS_PLUGIN, $WS_ATOM_NS, $WS_APP_NS, $WS_EXTN_NS, $WS_VERBOSE,
! $_CONF;
!
! if ($WS_VERBOSE) {
! COM_errorLog("WS: DELETE request received");
! }
WS_dissectURI($args);
***************
*** 353,357 ****
WS_error($ret, $svc_msg['error_desc']);
-
}
--- 385,388 ----
***************
*** 617,628 ****
function WS_authenticate()
{
! global $_USER;
$uid = '';
if (isset($_SERVER['PHP_AUTH_USER'])) {
$username = $_SERVER['PHP_AUTH_USER'];
$password = $_SERVER['PHP_AUTH_PW'];
!
$status = SEC_authenticate($username, $password, $uid);
} elseif (!empty($_REQUEST['gl_auth_header'])) {
--- 648,664 ----
function WS_authenticate()
{
! global $_USER, $_GROUPS, $_RIGHTS, $WS_VERBOSE;
$uid = '';
+ $status = -1;
if (isset($_SERVER['PHP_AUTH_USER'])) {
$username = $_SERVER['PHP_AUTH_USER'];
$password = $_SERVER['PHP_AUTH_PW'];
!
! if ($WS_VERBOSE) {
! COM_errorLog("WS: Attempting to log in user '$username'");
! }
!
$status = SEC_authenticate($username, $password, $uid);
} elseif (!empty($_REQUEST['gl_auth_header'])) {
***************
*** 635,648 ****
list($username, $password) = explode(':', base64_decode($auth_data));
$status = SEC_authenticate($username, $password, $uid);
} else {
return;
}
! if ($status == -1) {
WS_error(PLG_RET_AUTH_FAILED);
- } elseif ($status == 3) {
- $_USER = SESS_getUserDataFromId ($uid);
- PLG_loginUser ($_USER['uid']);
}
--- 671,696 ----
list($username, $password) = explode(':', base64_decode($auth_data));
+ if ($WS_VERBOSE) {
+ COM_errorLog("WS: Attempting to log in user '$username' (via gl_auth_header)");
+ }
+
$status = SEC_authenticate($username, $password, $uid);
} else {
+ if ($WS_VERBOSE) {
+ COM_errorLog("WS: No login given");
+ }
+
return;
}
! if ($status == USER_ACCOUNT_ACTIVE) {
! $_USER = SESS_getUserDataFromId($uid);
! PLG_loginUser($_USER['uid']);
!
! if ($WS_VERBOSE) {
! COM_errorLog("WS: User '{$_USER['username']}' ({$_USER['uid']}) successfully logged in");
! }
! } else {
WS_error(PLG_RET_AUTH_FAILED);
}
***************
*** 661,665 ****
*/
! $_RIGHTS = explode( ',', SEC_getUserPermissions() );
}
--- 709,713 ----
*/
! $_RIGHTS = explode(',', SEC_getUserPermissions());
}
More information about the geeklog-cvs
mailing list