[20854] update core

Sigurd Nes <[email protected]>
Newsgroups gmane.comp.web.phpgroupware.cvs
Message-ID <[email protected]>
Revision: 20854
          http://svn.sv.gnu.org/viewvc/?view=rev&root=phpgroupware&revision=20854
Author:   sigurdne
Date:     2009-11-20 10:35:12 +0000 (Fri, 20 Nov 2009)
Log Message:
-----------
update core

Modified Paths:
--------------
    people/sigurdne/core/trunk/anon_wrapper.php
    people/sigurdne/core/trunk/header.inc.php.template
    people/sigurdne/core/trunk/help.php
    people/sigurdne/core/trunk/home.php
    people/sigurdne/core/trunk/index.php
    people/sigurdne/core/trunk/login.php
    people/sigurdne/core/trunk/logout.php
    people/sigurdne/core/trunk/redirect.php
    people/sigurdne/core/trunk/set_box.php
    people/sigurdne/core/trunk/soap.php
    people/sigurdne/core/trunk/xmlrpc.php

Added Paths:
-----------
    people/sigurdne/core/trunk/.gitignore

Added: people/sigurdne/core/trunk/.gitignore
===================================================================
--- people/sigurdne/core/trunk/.gitignore	                        (rev 0)
+++ people/sigurdne/core/trunk/.gitignore	2009-11-20 10:35:12 UTC (rev 20854)
@@ -0,0 +1,5 @@
+.DS_Store
+/header.inc.php
+/.cache
+/.settings
+/.project
\ No newline at end of file

Modified: people/sigurdne/core/trunk/anon_wrapper.php
===================================================================
--- people/sigurdne/core/trunk/anon_wrapper.php	2009-11-20 10:29:32 UTC (rev 20853)
+++ people/sigurdne/core/trunk/anon_wrapper.php	2009-11-20 10:35:12 UTC (rev 20854)
@@ -5,20 +5,22 @@
 	* phpgroupware base
 	* @author Dan Kuykendall <[email protected]>
 	* @author Joseph Engo <[email protected]>
-	* @copyright Copyright (C) 2000-2005 Free Software Foundation, Inc. http://www.fsf.org/
+	* @copyright Copyright (C) 2000-2008 Free Software Foundation, Inc. http://www.fsf.org/
 	* @license http://www.gnu.org/licenses/gpl.html GNU General Public License
 	* @package phpgroupware
 	* @version $Id$
 	* @todo Limit which users can access this program (ACL check)
-	* @todo Global disabler
 	* @todo Detect bad logins and passwords, spit out generic message
 	*/
 
+	exit;
+
 	// If your are going to use multiable accounts, remove the following lines
 	$login  = 'anonymous';
 	$passwd = 'anonymous';
 
-	$GLOBALS['phpgw_info']['flags'] = array(
+	$GLOBALS['phpgw_info']['flags'] = array
+	(
 		'disable_Template_class' => True,
 		'login' => True,
 		'currentapp' => 'login',
@@ -36,6 +38,5 @@
 	$login  = 'anonymous'; 
 	$passwd = 'anonymous'; 
 
-	$sessionid = $GLOBALS['phpgw']->session->create($login,$passwd,'text');
+	$sessionid = $GLOBALS['phpgw']->session->create($login, $passwd);
 	$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/index.php'));
-?>

Modified: people/sigurdne/core/trunk/header.inc.php.template
===================================================================
--- people/sigurdne/core/trunk/header.inc.php.template	2009-11-20 10:29:32 UTC (rev 20853)
+++ people/sigurdne/core/trunk/header.inc.php.template	2009-11-20 10:35:12 UTC (rev 20854)
@@ -6,16 +6,17 @@
 	* @author Dan Kuykendall <[email protected]>
 	* @author Joseph Engo <[email protected]>
 	* @author Dave Hall <[email protected]>
-	* @copyright Copyright (C) 2000-2008 Free Software Foundation, Inc. http://www.fsf.org/
+ 	* @author Sigurd Nes <[email protected]>
+ 	* @copyright Copyright (C) 2000-2009 Free Software Foundation, Inc. http://www.fsf.org/
 	* @license http://www.gnu.org/licenses/gpl.html GNU General Public License
 	* @package phpgroupware
-	* @version $Id$
+ 	* @version $Id$
 	*/
 
 	/*
 	   This program is free software: you can redistribute it and/or modify
 	   it under the terms of the GNU General Public License as published by
-	   the Free Software Foundation, either version 3 of the License, or
+ 	   the Free Software Foundation, either version 2 of the License, or
 	   (at your option) any later version.
 
 	   This program is distributed in the hope that it will be useful,
@@ -27,6 +28,7 @@
 	   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 	 */
 
+
 	// **************************************************************************
 	// !!!!!!! EDIT THESE LINES !!!!!!!!
 	// This setting allows you to easily move the include directory and the
@@ -58,17 +60,13 @@
 	$GLOBALS['phpgw_info'] = array('flags' => $flags);
 	unset($flags);
 
-	/*
-	* Set the default charset which should solve some issues
-	*/
-	ini_set('default_charset', 'UTF-8');
-
 	/**
 	* @global string $phpgw_info['server']['header_admin_password'] Setup administrator password
 	*/
 	$GLOBALS['phpgw_info']['server']['header_admin_password'] = '{HEADER_ADMIN_PASSWORD}';
 
 	// phpGroupWare domain-specific db settings
+	// Note that with mcrypt enabled- the database settings are encrypted (the web-interface has to be used to produce the settings)
 	{domains}
 
 	/**
@@ -98,7 +96,7 @@
 	* phpGroupWare offers 2 session management systems - php and db
 	* Unless you really know what you are doing use php here as it works better 99.5% of the time
 	*/
-	$phpgw_info['server']['sessions_type'] = '{SESSIONS_TYPE}';
+ 	$GLOBALS['phpgw_info']['server']['sessions_type'] = '{SESSIONS_TYPE}';
 
 	/**
 	* @global string $phpgw_info['login_template_set']
@@ -113,12 +111,6 @@
 	$GLOBALS['phpgw_info']['server']['mcrypt_enabled'] = {ENABLE_MCRYPT};
 
 	/**
-	* @global string $phpgw_info['server']['versions']['mcrypt']
-	* Set this to 'old' for versions < 2.4, otherwise the exact mcrypt version you use. 
-	*/
-	$GLOBALS['phpgw_info']['server']['versions']['mcrypt'] = '{MCRYPT_VERSION}';
-
-	/**
 	* @global string $phpgw_info['server']['mcrypt_iv']
 	* This is a random string used as the initialization vector for mcrypt
 	* feel free to change it when setting up phpgroupware on a clean database,
@@ -127,6 +119,14 @@
 	*/
 	$GLOBALS['phpgw_info']['server']['mcrypt_iv'] = '{MCRYPT_IV}';
 
+	/**
+	* @global string $phpgw_info['server']['setup_mcrypt_key']
+	* This is a random string used as the encryption key for mcrypt
+	* feel free to change it when setting up phpgroupware on a clean database,
+	* but you must not change it after that point!
+	*/
+	$GLOBALS['phpgw_info']['server']['setup_mcrypt_key'] = '{SETUP_MCRYPT_KEY}';
+
 	/*
 		This ensures IE gets the right character set
 	*/
@@ -199,20 +199,22 @@
 	* @global string $phpgw_info['server']['versions']['header']
 	* Version of this header file
 	*/
-	$GLOBALS['phpgw_info']['server']['versions']['header'] = '1.28';
+	$GLOBALS['phpgw_info']['server']['versions']['header'] = '1.29';
 	
 	
-	if(!isset($GLOBALS['phpgw_info']['flags']['noapi']) || $GLOBALS['phpgw_info']['flags']['noapi'] != True)
+	if ( !isset($GLOBALS['phpgw_info']['flags']['noapi'])
+		|| !$GLOBALS['phpgw_info']['flags']['noapi'] )
 	{
 		/**
 		* Include global general functions
 		*/
-		include(PHPGW_API_INC . '/functions.inc.php');
+		require_once PHPGW_API_INC . '/functions.inc.php';
 	}
 
 	// Leave off the final php closing tag, some editors will add
 	// a \n or space after which will mess up cookies later on
 <!-- BEGIN domain -->
+
 	$GLOBALS['phpgw_domain']['{DB_DOMAIN}'] = array
 	(
 		'db_host' => '{DB_HOST}', 
@@ -221,7 +223,6 @@
 		'db_pass' => '{DB_PASS}', 
 		// Look at the README file
 		'db_type' => '{DB_TYPE}',
-		// This will limit who is allowed to make configuration modifications
 		'config_passwd' => '{CONFIG_PASS}'
 	);
 

Modified: people/sigurdne/core/trunk/help.php
===================================================================
--- people/sigurdne/core/trunk/help.php	2009-11-20 10:29:32 UTC (rev 20853)
+++ people/sigurdne/core/trunk/help.php	2009-11-20 10:35:12 UTC (rev 20854)
@@ -16,7 +16,7 @@
 	*/
 	$GLOBALS['phpgw_info'] = array();
 
-	$app = $HTTP_GET_VARS['app'];
+	$app = $_GET['app'];
 
 	if (!$app)
 	{

Modified: people/sigurdne/core/trunk/home.php
===================================================================
--- people/sigurdne/core/trunk/home.php	2009-11-20 10:29:32 UTC (rev 20853)
+++ people/sigurdne/core/trunk/home.php	2009-11-20 10:35:12 UTC (rev 20854)
@@ -18,11 +18,11 @@
 	$GLOBALS['phpgw_info']['flags'] = array
 	(
 		'noheader'                => true,
-		'nonavbar'                => true,
+		'nonavbar'                => false,
 		'currentapp'              => 'home',
-		'enable_network_class'    => True,
-		'enable_contacts_class'   => True,
-		'enable_nextmatchs_class' => True
+		'enable_network_class'    => true,
+		'enable_contacts_class'   => true,
+		'enable_nextmatchs_class' => true
 	);
 	
 	/**

Modified: people/sigurdne/core/trunk/index.php
===================================================================
--- people/sigurdne/core/trunk/index.php	2009-11-20 10:29:32 UTC (rev 20853)
+++ people/sigurdne/core/trunk/index.php	2009-11-20 10:35:12 UTC (rev 20854)
@@ -13,7 +13,7 @@
 	/*
 	   This program is free software: you can redistribute it and/or modify
 	   it under the terms of the GNU General Public License as published by
-	   the Free Software Foundation, either version 3 of the License, or
+	   the Free Software Foundation, either version 2 of the License, or
 	   (at your option) any later version.
 
 	   This program is distributed in the hope that it will be useful,

Modified: people/sigurdne/core/trunk/login.php
===================================================================
--- people/sigurdne/core/trunk/login.php	2009-11-20 10:29:32 UTC (rev 20853)
+++ people/sigurdne/core/trunk/login.php	2009-11-20 10:35:12 UTC (rev 20854)
@@ -11,8 +11,12 @@
 	* @version $Id$
 	*/
 
-	chdir('phpgwapi/inc/sso');
-   	include_once('include_login.inc.php');
+	 if(isset($_REQUEST['skip_remote']) && $_REQUEST['skip_remote'])
+	 {
+	 		$GLOBALS['phpgw_remote_user_fallback'] = 'sql';
+	 }
+	 
+	require_once 'phpgwapi/inc/sso/include_login.inc.php';
 
 	$partial_url = 'login.php';
 	$phpgw_url_for_sso = 'phpgwapi/inc/sso/login_server.php';
@@ -50,7 +54,6 @@
 		{
 			$_POST['submitit'] = true;
 		}
-		$_POST['passwd_type'] = 'text';
 	}
 	else
 	{
@@ -65,11 +68,50 @@
 		$passwd = $_SERVER['PHP_AUTH_PW'];
 	}
 	
-	if ($GLOBALS['phpgw_info']['server']['auth_type'] == 'ntlm' && isset($_SERVER['REMOTE_USER']))
+	if ($GLOBALS['phpgw_info']['server']['auth_type'] == 'ntlm' && isset($_SERVER['REMOTE_USER']) && (!isset($_REQUEST['skip_remote']) || !$_REQUEST['skip_remote']))
 	{
-		$submit = true;
 		$login  = $_SERVER['REMOTE_USER'];
 		$passwd = '';
+//------------------Start login ntlm
+
+		$GLOBALS['sessionid'] = $GLOBALS['phpgw']->session->create($login, $passwd);
+
+		if (! isset($GLOBALS['sessionid']) || ! $GLOBALS['sessionid'])
+		{
+			$cd_array=array();
+			if($GLOBALS['phpgw']->session->cd_reason)
+			{
+				$cd_array['cd'] = $GLOBALS['phpgw']->session->cd_reason;
+			}
+			$cd_array['skip_remote'] = true;
+
+			$GLOBALS['phpgw']->redirect_link("/{$partial_url}", $cd_array);
+			exit;
+		}
+
+		$forward = phpgw::get_var('phpgw_forward');
+		if($forward)
+		{
+			$extra_vars['phpgw_forward'] =  $forward;
+			foreach($_GET as $name => $value)
+			{
+				if (ereg('phpgw_',$name))
+				{
+					$name = urlencode($name);
+					$extra_vars[$name] = urlencode($value);
+				}
+			}
+		}
+		if ( !isset($GLOBALS['phpgw_info']['server']['disable_autoload_langfiles']) || !$GLOBALS['phpgw_info']['server']['disable_autoload_langfiles'] )
+		{
+			$uilogin->check_langs();
+		}
+		$extra_vars['cd'] = 'yes';
+		
+		$GLOBALS['phpgw']->hooks->process('login');
+		$GLOBALS['phpgw']->redirect_link('/home.php', $extra_vars);
+
+//----------------- End login ntlm
 	}
 
 	# Apache + mod_ssl style SSL certificate authentication
@@ -104,7 +146,7 @@
 		unset($sslattributes);
 	}
 
-	if (isset($_POST['passwd_type']) && (isset($_POST['submitit']) || isset($_POST['submit_x']) || isset($_POST['submit_y']) ) )
+	if ( (isset($_POST['submitit']) || isset($_POST['submit_x']) || isset($_POST['submit_y']) ) )
 	{
 		if ( $_SERVER['REQUEST_METHOD'] != 'POST' &&
 		   !isset($_SERVER['PHP_AUTH_USER']) &&
@@ -115,18 +157,24 @@
 			$GLOBALS['phpgw']->redirect_link('/'.$partial_url, array('cd' => '5'));
 		}
 
-		if (strstr($login,'@') === false && isset($_POST['logindomain']))
+		$logindomain = phpgw::get_var('logindomain', 'string', 'POST');
+		if ( strstr($login,'@') === false && $logindomain )
 		{
-			$login .= '@' . $_POST['logindomain'];
+			$login .= "@{$logindomain}";
 		}
 
-		//XXX Caeies nov 08 The third argument is wrong so change the code
-		/*
-		$passwd_type = $_POST['passwd_type'] == 'md5' ? 'md5' : 'text';
-		$GLOBALS['sessionid'] = $GLOBALS['phpgw']->session->create($login, $passwd, $passwd_type);
-		*/
-		$GLOBALS['sessionid'] = $GLOBALS['phpgw']->session->create($login, $passwd, false);
+		if ( isset($GLOBALS['phpgw_info']['server']['usecookies'])
+			&& $GLOBALS['phpgw_info']['server']['usecookies'] )
+		{
+			if(isset($_COOKIE['domain']) && $_COOKIE['domain'] != $logindomain)
+			{
+				$GLOBALS['phpgw']->redirect_link("/{$partial_url}", array('cd' =>22)); // already within a session
+				exit;
+			}
+		}
 
+		$GLOBALS['sessionid'] = $GLOBALS['phpgw']->session->create($login, $passwd);
+
 		if (! isset($GLOBALS['sessionid']) || ! $GLOBALS['sessionid'])
 		{
 			$cd_array=array();
@@ -134,7 +182,8 @@
 			{
 				$cd_array['cd'] = $GLOBALS['phpgw']->session->cd_reason;
 			}
-			$GLOBALS['phpgw']->redirect_link('/'.$partial_url, $cd_array);
+			$cd_array['skip_remote'] = true;
+			$GLOBALS['phpgw']->redirect_link("/{$partial_url}", $cd_array);
 			exit;
 		}
 
@@ -146,7 +195,9 @@
 			{
 				if (ereg('phpgw_',$name))
 				{
-					$extra_vars[$name] = $value;
+					//$extra_vars[$name] = $value;
+					$name = urlencode($name);
+					$extra_vars[$name] = urlencode($value);
 				}
 			}
 		}
@@ -157,19 +208,8 @@
 		$extra_vars['cd'] = 'yes';
 		
 		$GLOBALS['phpgw']->hooks->process('login');
-
-		if( isset($GLOBALS['phpgw_info']['server']['shm_lang']) 
-			&& $GLOBALS['phpgw_info']['server']['shm_lang'] 
-			&& function_exists('sem_get'))
-		{
-			if(!$GLOBALS['phpgw']->shm->get_value('lang_en'))
-			{
-				$GLOBALS['phpgw']->translation->populate_shm();
-			}
-		}
-
+//		$GLOBALS['phpgw']->translation->populate_cache(); // moved to sesssion::verify()
 		$GLOBALS['phpgw']->redirect_link('/home.php', $extra_vars);
-		exit;
 	}
 
 	//Build vars :

Modified: people/sigurdne/core/trunk/logout.php
===================================================================
--- people/sigurdne/core/trunk/logout.php	2009-11-20 10:29:32 UTC (rev 20853)
+++ people/sigurdne/core/trunk/logout.php	2009-11-20 10:35:12 UTC (rev 20854)
@@ -25,13 +25,12 @@
 	*/
 	include_once('header.inc.php');
 
-	$sessionid = phpgw::get_var('sessionid');
-	$kp3       = phpgw::get_var('kp3');
+	$sessionid = phpgw::get_var('sessionphpgwsessid');
 
 	$verified = $GLOBALS['phpgw']->session->verify();
 	if ($verified)
 	{
-		if ( !empty($session_id) && is_dir("{$GLOBALS['phpgw_info']['server']['temp_dir']}/{$sessionid}") )
+		if ( is_dir("{$GLOBALS['phpgw_info']['server']['temp_dir']}/{$sessionid}") && !empty($session_id) )
 		{
 			$dh = dir("{$GLOBALS['phpgw_info']['server']['temp_dir']}/{$sessionid}");
 			while ( ($file = $dh->read()) !== false )
@@ -45,8 +44,9 @@
 			rmdir("{$GLOBALS['phpgw_info']['server']['temp_dir']}/{$sessionid}");
 			$dh->close();
 		}
+		execMethod('phpgwapi.menu.clear');
 		$GLOBALS['phpgw']->hooks->process('logout');
-		$GLOBALS['phpgw']->session->destroy($sessionid,$kp3);
+		$GLOBALS['phpgw']->session->destroy($sessionid);
 	}
 	else
 	{
@@ -59,12 +59,12 @@
 			));
 		}
 	}
-	$GLOBALS['phpgw']->session->phpgw_setcookie('sessionid');
-	$GLOBALS['phpgw']->session->phpgw_setcookie('kp3');
-	$GLOBALS['phpgw']->session->phpgw_setcookie('domain');
-	if($GLOBALS['phpgw_info']['server']['sessions_type'] == 'php')
+
+	if ( isset($GLOBALS['phpgw_info']['server']['usecookies'])
+		&& $GLOBALS['phpgw_info']['server']['usecookies'] )
 	{
-		$GLOBALS['phpgw']->session->phpgw_setcookie('PHPGW_PHPSESSID');
+		$GLOBALS['phpgw']->session->phpgw_setcookie('sessionphpgwsessid');
+		$GLOBALS['phpgw']->session->phpgw_setcookie('domain');
 	}
 
-	$GLOBALS['phpgw']->redirect($GLOBALS['phpgw_info']['server']['webserver_url'].'/login.php?cd=1');
+	$GLOBALS['phpgw']->redirect_link('/login.php', array('cd' => 1));

Modified: people/sigurdne/core/trunk/redirect.php
===================================================================
--- people/sigurdne/core/trunk/redirect.php	2009-11-20 10:29:32 UTC (rev 20853)
+++ people/sigurdne/core/trunk/redirect.php	2009-11-20 10:35:12 UTC (rev 20854)
@@ -6,25 +6,10 @@
 	* @internal Idea by Jason Wies <[email protected]>
 	* @author Lars Kneschke <[email protected]>
 	* @author Dave Hall <[email protected]>
-	* @copyright Copyright (C) 2004 - 2008 Free Software Foundation, Inc. http://www.fsf.org/
-	* @license http://www.fsf.org/licenses/gpl.html GNU General Public License v3 or later
+	* @copyright Copyright (C) 2004-2005 Free Software Foundation, Inc. http://www.fsf.org/
+	* @license http://www.gnu.org/licenses/gpl.html GNU General Public License
 	* @package phpgroupware
 	* @version $Id$
-	*/
- 
-	/*
-	   This program is free software: you can redistribute it and/or modify
-	   it under the terms of the GNU General Public License as published by
-	   the Free Software Foundation, either version 3 of the License, or
-	   (at your option) any later version.
-
-	   This program is distributed in the hope that it will be useful,
-	   but WITHOUT ANY WARRANTY; without even the implied warranty of
-	   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-	   GNU Lesser General Public License for more details.
-
-	   You should have received a copy of the GNU Lesser General Public License
-	   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 	 */
 
 	//Get the session variables set for non cookie based sessions
@@ -65,13 +50,13 @@
 
 	if( isset($_GET['go']) )
 	{
-		$_GET['go'] = html_entity_decode($_GET['go']);
+		$_GET['go'] = htmlspecialchars_decode(urldecode($_GET['go']));
 		?>
-			<h2><?php lang('external link'); ?></h2>
-			<p><?php lang('lang you are about to visit an external site'); ?><br />
-			<?php lang('vist:'); ?> <a href="<?php echo $_GET['go']; ?>" 
+			<h2><?php echo lang('external link'); ?></h2>
+			<p><?php echo lang('lang you are about to visit an external site'); ?><br />
+			<?php echo lang('vist:'); ?> <a href="<?php echo $_GET['go']; ?>" 
 				target="_blank"><?php echo $_GET['go']; ?></a></p>
-			<script language="JavaScript" type="text/javascript">window.location='<?php echo$_GET['go']; ?>';</script>
+			<script language="JavaScript" type="text/javascript">window.location="<?php echo$_GET['go']; ?>";</script>
 		<?php
 	        exit;
 	}

Modified: people/sigurdne/core/trunk/set_box.php
===================================================================
--- people/sigurdne/core/trunk/set_box.php	2009-11-20 10:29:32 UTC (rev 20853)
+++ people/sigurdne/core/trunk/set_box.php	2009-11-20 10:35:12 UTC (rev 20854)
@@ -105,5 +105,3 @@
 
 	Header('Location: '.$GLOBALS['phpgw']->link('/home.php'));
 	$GLOBALS['phpgw']->common->phpgw_exit();
-?>
-

Modified: people/sigurdne/core/trunk/soap.php
===================================================================
--- people/sigurdne/core/trunk/soap.php	2009-11-20 10:29:32 UTC (rev 20853)
+++ people/sigurdne/core/trunk/soap.php	2009-11-20 10:35:12 UTC (rev 20854)
@@ -2,90 +2,207 @@
 	/**
 	* phpGroupWare
 	*
-	* phpgroupware base
 	* @author Miles Lott <[email protected]>
-	* @copyright Copyright (C) 2000-2005 Free Software Foundation, Inc. http://www.fsf.org/
+	* @author Sigurd Nes <[email protected]>
+	* @copyright Copyright (C) 2000-2009 Free Software Foundation, Inc. http://www.fsf.org/
+	* This file is part of phpGroupWare.
+	*
+	* phpGroupWare is free software; you can redistribute it and/or modify
+	* it under the terms of the GNU General Public License as published by
+	* the Free Software Foundation; either version 2 of the License, or
+	* (at your option) any later version.
+	*
+	* phpGroupWare is distributed in the hope that it will be useful,
+	* but WITHOUT ANY WARRANTY; without even the implied warranty of
+	* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+	* GNU General Public License for more details.
+	*
+	* You should have received a copy of the GNU General Public License
+	* along with phpGroupWare; if not, write to the Free Software
+	* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+	*
 	* @license http://www.gnu.org/licenses/gpl.html GNU General Public License
-	* @package phpgroupware
-	* @version $Id$
+	* @internal Development of this application was funded by http://www.bergen.kommune.no/bbb_/ekstern/
+	* @package soap
+	* @subpackage communication
+ 	* @version $Id$
 	*/
 
+
 	$GLOBALS['phpgw_info'] = array();
 
 	$GLOBALS['phpgw_info']['flags'] = array
 	(
 		'disable_Template_class'	=> true,
 		'currentapp'				=> 'login',
-		'noheader'					=> true
+		'noheader'					=> true,
+		'noapi'						=> true		// this stops header.inc.php to include phpgwapi/inc/function.inc.php
 	);
 
 	/**
 	* Include phpgroupware header
 	*/
+
 	include_once('header.inc.php');
 
-	/**
-	* Include the SOAP specific functions
-	*/
-	include_once(PHPGW_API_INC . '/soap_functions.inc.php');
+	unset($GLOBALS['phpgw_info']['flags']['noapi']);
+	$GLOBALS['phpgw_info']['flags']['authed'] = false;
+	$GLOBALS['phpgw_info']['message']['errors'] = array();
 
-	/**
-	* @global object $GLOBALS['server']
-	*/
-	$GLOBALS['server'] = CreateObject('phpgwapi.soap_server');
+	if(!isset($_GET['domain']) || !$_GET['domain'])
+	{
+		$GLOBALS['phpgw_info']['message']['errors'][] = 'domain not given as input';
+	}
+	else
+	{
+		$_REQUEST['domain'] = $_GET['domain'];
+		$_domain_info = isset($GLOBALS['phpgw_domain'][$_GET['domain']]) ? $GLOBALS['phpgw_domain'][$_GET['domain']] : '';
+		if(!$_domain_info)
+		{
+			$GLOBALS['phpgw_info']['message']['errors'][] = 'not a valid domain';
+		}
+		else
+		{
+			$GLOBALS['phpgw_domain'] = array();
+			$GLOBALS['phpgw_domain'][$_GET['domain']] = $_domain_info;
+		}
+	}
 
-	/* _debug_array($GLOBALS['server']);exit; */
-	/* include(PHPGW_API_INC . '/soaplib.soapinterop.php'); */
+	include(PHPGW_API_INC.'/functions.inc.php');
 
 	$headers = getallheaders();
-
 	if(ereg('Basic',$headers['Authorization']))
 	{
-		//this seems silly to me - why not just use the SERVER vars? skwashd
 		$tmp = $headers['Authorization'];
-		$tmp = ereg_replace(' ','',$tmp);
-		$tmp = ereg_replace('Basic','',$tmp);
+		$tmp = str_replace(' ','',$tmp);
+		$tmp = str_replace('Basic','',$tmp);
 		$auth = base64_decode(trim($tmp));
-		list($sessionid,$kp3) = split(':',$auth);
+		list($login,$password) = split(':',$auth);
 
-		if($GLOBALS['phpgw']->session->verify($sessionid,$kp3))
+		if($GLOBALS['phpgw']->session->create($login, $password))
 		{
-			$GLOBALS['server']->authed = True;
+			$GLOBALS['phpgw_info']['flags']['authed'] = true;
 		}
-		elseif($GLOBALS['phpgw']->session->verify_server($sessionid,$kp3))
+		else
 		{
-			$GLOBALS['server']->authed = True;
+			$GLOBALS['phpgw_info']['message']['errors'][] = 'not authenticated';
 		}
 	}
 
-	$GLOBALS['server']->add_to_map(
-		'system_login',
-		array('soapstruct'),
-		array('soapstruct')
+	/**
+	* @global object $GLOBALS['server']
+	*/
+	
+	$wdsl = null;
+	$options = array
+	(
+		'uri'          => "http://test-uri/", # the name space of the SOAP service
+		'soap_version' => SOAP_1_2,
+	//	'actor'        => "...", # the actor
+		'encoding'     => "UTF-8", # the encoding name
+	//	'classmap'     => "...", # a map of WSDL types to PHP classes
 	);
-	$GLOBALS['server']->add_to_map(
-		'system_logout',
-		array('soapstruct'),
-		array('soapstruct')
-	);
 
-	if(function_exists('system_listapps'))
+	$GLOBALS['server'] = new SoapServer($wdsl, $options);
+
+
+	$functions = array();
+	/**
+	* Include SOAP specific functions - Sigurd: Think these are obsolete.
+	*/
+//	include_once(PHPGW_API_INC . '/soap_functions.inc.php');
+//	$functions = array('system_login', 'system_logout');
+
+	if(function_exists('system_list_apps'))
 	{
-		$GLOBALS['server']->add_to_map(
-			'system_listApps',
-			array(),
-			array('soapstruct')
+		$functions[] = 'system_list_apps';
+	}
+
+	function hello($someone)
+	{
+		return "Hello " . $someone . "! - SOAP 1.2";
+	} 
+
+	$functions[] = 'hello';
+
+/*
+	function displayheaders($data)
+	{
+		return getallheaders();
+	} 
+
+	$functions[] = 'displayheaders';
+
+*/
+	function execute($data)
+	{
+		if( isset($GLOBALS['phpgw_info']['message']['errors']) && $GLOBALS['phpgw_info']['message']['errors'] )
+		{
+    		$error = 'Error(s): ' . implode(' ## AND ## ', $GLOBALS['phpgw_info']['message']['errors']);
+    		return new SoapFault("phpgw", $error);
+		}
+
+		//to be sure...
+		if( !$GLOBALS['phpgw_info']['flags']['authed'] )
+		{
+    		return new SoapFault("phpgw", 'not authenticated');
+		}
+
+		$GLOBALS['phpgw_info']['flags'] = array
+		(
+			'disable_template_class' => true,
+			'login'                  => true,
+			'currentapp'             => 'login',
+			'noheader'               => true
 		);
+
+		$invalid_data = false;
+		if (! $data['app'] || ! $data['class'] || ! $data['method'])
+		{
+			$invalid_data = true;
+		}
+
+		$obj = CreateObject("{$data['app']}.{$data['class']}");
+
+		if ( !$invalid_data 
+			&& is_object($obj)
+			&& isset($obj->soap_enabled) 
+			&& is_array($obj->soap_enabled) 
+			&& isset($obj->soap_enabled[$data['method']])
+			&& $obj->soap_enabled[$data['method']])
+		{
+			return $obj->$data['method']($data['input']);
+		}
+		else
+		{
+			return 'The method has to be "soap_enabled" - that is - ACL-check for righst for remote users at this particular method';
+		}
 	}
 
+	$functions[] = 'execute';
+
+	$GLOBALS['server']->addFunction($functions);
+//	$GLOBALS['server']->addFunction(SOAP_FUNCTIONS_ALL);
+
 	if ( isset($HTTP_RAW_POST_DATA) )
 	{
 		$request_xml = $HTTP_RAW_POST_DATA;
 	}
 	else
 	{
-		$request_xml = implode("\r\n", file('php://input'));
+		$request_xml = implode(" ", file('php://input'));
 	}
 
-	$GLOBALS['server']->service($request_xml);
+	if ($_SERVER["REQUEST_METHOD"] == "POST")
+	{
+		$GLOBALS['server']->handle($request_xml);
+	}
+	else
+	{
+		echo "This SOAP server can handle following functions: ";
+
+		_debug_array($functions = $GLOBALS['server']->getFunctions());
+
+	}
+	$GLOBALS['phpgw']->common->phpgw_exit();
 ?>

Modified: people/sigurdne/core/trunk/xmlrpc.php
===================================================================
--- people/sigurdne/core/trunk/xmlrpc.php	2009-11-20 10:29:32 UTC (rev 20853)
+++ people/sigurdne/core/trunk/xmlrpc.php	2009-11-20 10:35:12 UTC (rev 20854)
@@ -2,33 +2,84 @@
 	/**
 	* phpGroupWare
 	*
-	* phpgroupware base
 	* @author Joseph Engo <[email protected]>
-	* @copyright Copyright (C) 2000-2005 Free Software Foundation, Inc. http://www.fsf.org/
+	* @author Sigurd Nes <[email protected]>
+	* @copyright Copyright (C) 2000-2009 Free Software Foundation, Inc. http://www.fsf.org/
+	* This file is part of phpGroupWare.
+	*
+	* phpGroupWare is free software; you can redistribute it and/or modify
+	* it under the terms of the GNU General Public License as published by
+	* the Free Software Foundation; either version 2 of the License, or
+	* (at your option) any later version.
+	*
+	* phpGroupWare is distributed in the hope that it will be useful,
+	* but WITHOUT ANY WARRANTY; without even the implied warranty of
+	* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+	* GNU General Public License for more details.
+	*
+	* You should have received a copy of the GNU General Public License
+	* along with phpGroupWare; if not, write to the Free Software
+	* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+	*
 	* @license http://www.gnu.org/licenses/gpl.html GNU General Public License
-	* @package phpgroupware
-	* @version $Id$
+	* @internal Development of this application was funded by http://www.bergen.kommune.no/bbb_/ekstern/
+	* @package xmlrpc
+	* @subpackage communication
+ 	* @version $Id$
 	*/
 	
+
 	$GLOBALS['phpgw_info'] = array();
 	
 	$GLOBALS['phpgw_info']['flags'] = array
 	(
+		'disable_Template_class'	=> true,
 		'currentapp'			=> 'login',
-		'noheader'				=> True,
-		'disable_Template_class'=> True
+		'noheader'					=> true,
+		'noapi'						=> true		// this stops header.inc.php to include phpgwapi/inc/function.inc.php
 	);
 	
 	/**
 	* Include phpgroupware header
 	*/
+
 	include_once('header.inc.php');
 
+	unset($GLOBALS['phpgw_info']['flags']['noapi']);
+	$GLOBALS['phpgw_info']['flags']['authed'] = false;
+	$GLOBALS['phpgw_info']['message']['errors'] = array();
+
+	if(!isset($_GET['domain']) || !$_GET['domain'])
+	{
+		$GLOBALS['phpgw_info']['message']['errors'][] = 'domain not given as input';
+	}
+	else
+	{
+		$_REQUEST['domain'] = $_GET['domain'];
+		$_domain_info = isset($GLOBALS['phpgw_domain'][$_GET['domain']]) ? $GLOBALS['phpgw_domain'][$_GET['domain']] : '';
+		if(!$_domain_info)
+		{
+			$GLOBALS['phpgw_info']['message']['errors'][] = 'not a valid domain';
+		}
+		else
+		{
+			$GLOBALS['phpgw_domain'] = array();
+			$GLOBALS['phpgw_domain'][$_GET['domain']] = $_domain_info;
+		}
+	}
+
+	include(PHPGW_API_INC.'/functions.inc.php');
+
+
 	/**
 	* Include the XMLRPC specific functions
 	*/
-	include_once(PHPGW_API_INC . '/xml_functions.inc.php');
+	require_once PHPGW_API_INC . '/xmlrpc/lib/xmlrpc.inc';
+	require_once PHPGW_API_INC . '/xmlrpc/lib/xmlrpcs.inc';
+	require_once PHPGW_API_INC . '/xmlrpc/lib/xmlrpc_wrappers.inc';
 
+//	include_once(PHPGW_API_INC . '/xml_functions.inc.php');
+
 	// If XML-RPC isn't enabled in PHP, return an XML-RPC response stating so
 	if (! function_exists('xmlrpc_server_create'))
 	{
@@ -75,11 +126,26 @@
 		$request_xml = implode("\r\n", file('php://input'));
 	}
 			
+	if(!$_domain_info)
+	{
+		// domain is invalid
+		xmlrpc_error(1001,'not a valid domain');
+	}
+//		xmlrpc_error(1001,$headers['Authorization']);
+
 	if ( isset($headers['Authorization']) 
 		&& ereg('Basic', $headers['Authorization']) )
 	{
-		if ( $GLOBALS['phpgw']->session->verify($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) )
+		$tmp = $headers['Authorization'];
+		$tmp = str_replace(' ','',$tmp);
+		$tmp = str_replace('Basic','',$tmp);
+		$auth = base64_decode(trim($tmp));
+		list($login,$password) = split(':',$auth);
+
+		if($GLOBALS['phpgw']->session->create($login, $password))
 		{
+			$GLOBALS['phpgw_info']['flags']['authed'] = true;
+
 			// Find out what method they are calling
 			// This function is odd, you *NEED* to assign the results
 			// to a value, or $method is never returned.  (jengo)
@@ -92,22 +158,25 @@
 			// for that class, and execute it
 			list($app,$class,$func) = explode('.',$method);
 
-			if ($method == 'system.logout' || $GLOBALS['phpgw_info']['user']['apps'][$app] || $app == 'phpgwapi')
+			if ($method == 'system.logout' || $GLOBALS['phpgw_info']['user']['apps'][$app] || $app == 'phpgwapi' || $app == 'xmlrpc')
 			{
 				$GLOBALS['obj'] = CreateObject($app . '.' . $class);
 
-				xmlrpc_server_register_method($xmlrpc_server,sprintf('%s.%s.%s',$app,$class,'listMethods'),'xmlrpc_list_methods');
-				xmlrpc_server_register_method($xmlrpc_server,sprintf('%s.%s.%s',$app,$class,'describeMethods'),xmlrpc_describe_methods);
-				xmlrpc_server_register_method($xmlrpc_server,'system.logout','xmlrpc_logout');
+				xmlrpc_server_register_method($GLOBALS['xmlrpc_server'],sprintf('%s.%s.%s',$app,$class,'list_methods'),'xmlrpc_list_methods');
+				xmlrpc_server_register_method($GLOBALS['xmlrpc_server'],sprintf('%s.%s.%s',$app,$class,'describeMethods'),'xmlrpc_describe_methods');
+				xmlrpc_server_register_method($GLOBALS['xmlrpc_server'],'system.logout','xmlrpc_logout');
 
-				while (list(,$new_method) = @each($obj->xmlrpc_methods))
+				if(isset($GLOBALS['obj']->xmlrpc_methods) && is_array($GLOBALS['obj']->xmlrpc_methods))
 				{
+					foreach ($GLOBALS['obj']->xmlrpc_methods as $new_method)
+				{
 					$full_method_name = sprintf('%s.%s.%s',$app,$class,$new_method['name']);
 
-					xmlrpc_server_register_method($xmlrpc_server,$full_method_name,'xmlrpc_call_wrapper');
+						xmlrpc_server_register_method($GLOBALS['xmlrpc_server'],$full_method_name,'xmlrpc_call_wrapper');
 					// The following function is listed as being in the API, but doesn't actually exisit.
 					// This is more of a mental note to track down its exisitence
-					//xmlrpc_server_set_method_description($xmlrpc_server,$full_method_name,$new_method);
+						//xmlrpc_server_set_method_description($GLOBALS['xmlrpc_server'],$full_method_name,$new_method);
+					}
 				}
 			}
 			else if ($method != 'system.listMethods' && $method != 'system.describeMethods')
@@ -115,13 +184,12 @@
 				xmlrpc_error(1001,'Access not permitted');
 			}
 
-			echo xmlrpc_server_call_method($xmlrpc_server,$request_xml,'');
-			xmlrpc_server_destroy($xmlrpc_server);
+			echo xmlrpc_server_call_method($GLOBALS['xmlrpc_server'],$request_xml,'');
+			xmlrpc_server_destroy($GLOBALS['xmlrpc_server']);
 		}
 		else
 		{
-			// Session is invalid
-			xmlrpc_error(1001,'Session expired');
+			xmlrpc_error(1001, 'not authenticated');
 		}
 	}
 	else
@@ -133,9 +201,9 @@
 
 		if ($method == 'system.login')
 		{
-			xmlrpc_server_register_method($xmlrpc_server,'system.login','xmlrpc_login');
-			echo xmlrpc_server_call_method($xmlrpc_server,$request_xml,'');
-			xmlrpc_server_destroy($xmlrpc_server);
+			xmlrpc_server_register_method($GLOBALS['xmlrpc_server'],'system.login','xmlrpc_login');
+			echo xmlrpc_server_call_method($GLOBALS['xmlrpc_server'],$request_xml,'');
+			xmlrpc_server_destroy($GLOBALS['xmlrpc_server']);
 
 			exit;
 		}
@@ -298,7 +366,7 @@
 			$username = $p['username'];
 		}
 
-		$sessionid = $GLOBALS['phpgw']->session->create($username,$p['password'],'text');
+		$sessionid = $GLOBALS['phpgw']->session->create($username, $p['password']);
 		$kp3       = $GLOBALS['phpgw']->session->kp3;
 		$domain    = $GLOBALS['phpgw']->session->account_domain;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.