From 0cc5b6dfb371e675478f709e340ef6a4bf42e62e Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Thu, 2 Aug 2007 21:19:54 +0000 Subject: [PATCH] Cleaned up the config interface. * Eliminated SOCKET_PREFIX because unix:// works on PHP4 too, so we can use it all the time. * Prefix has been moved to CITADEL_HOSTNAME * Added config_ctdlclient_local.php and added it to .svnignore, so site operators and developers can override without wreaking havoc in svn. --- ctdlphp/.svnignore | 1 + ctdlphp/config_ctdlclient.php | 41 +++++++++++++++++++++++++---------- ctdlphp/ctdlsession.php | 2 +- ctdlphp/sessionproxy.php | 4 ++-- 4 files changed, 33 insertions(+), 15 deletions(-) create mode 100644 ctdlphp/.svnignore diff --git a/ctdlphp/.svnignore b/ctdlphp/.svnignore new file mode 100644 index 000000000..6e158d8c9 --- /dev/null +++ b/ctdlphp/.svnignore @@ -0,0 +1 @@ +config_ctdlclient_local.php diff --git a/ctdlphp/config_ctdlclient.php b/ctdlphp/config_ctdlclient.php index bfedf45fc..bcbdf45c1 100644 --- a/ctdlphp/config_ctdlclient.php +++ b/ctdlphp/config_ctdlclient.php @@ -1,16 +1,33 @@ \ No newline at end of file +// Examples: +// +// On the same host: +// unix:///var/run/citadel/citadel.sock +// +// On a different host (or via loopback): +// tcp://citserver.example.com +// tcp://127.0.0.1 + +if (!defined('CITADEL_HOSTNAME')) { + define('CITADEL_HOSTNAME',"tcp://127.0.0.1"); +} + +// make it 0 to use unix domain sockets +if (!defined('CITADEL_TCP_PORTNO')) { + define('CITADEL_TCP_PORTNO','504'); +} + +// do you want to see the server conversation for exploring the protocol? +if (!defined('CITADEL_DEBUG_CITPROTO')) { + define('CITADEL_DEBUG_CITPROTO',0); +} +if (!defined('CITADEL_DEBUG_PROXY')) { + define('CITADEL_DEBUG_PROXY', FALSE); +} + +?> diff --git a/ctdlphp/ctdlsession.php b/ctdlphp/ctdlsession.php index 988839cc8..672d6f636 100644 --- a/ctdlphp/ctdlsession.php +++ b/ctdlphp/ctdlsession.php @@ -35,7 +35,7 @@ function establish_citadel_session() { $sockname = "/tmp/" . $session . ".socket" ; - $clientsocket = fsockopen(SOCKET_PREFIX.$sockname, 0, $errno, $errstr, 5); + $clientsocket = fsockopen('unix://' . $sockname, 0, $errno, $errstr, 5); if (!$clientsocket) { // It ain't there, dude. Open up the proxy. (C version) //$cmd = "./sessionproxy " . $sockname ; diff --git a/ctdlphp/sessionproxy.php b/ctdlphp/sessionproxy.php index fdb7b699d..22f4d4a0e 100755 --- a/ctdlphp/sessionproxy.php +++ b/ctdlphp/sessionproxy.php @@ -14,10 +14,10 @@ include "config_ctdlclient.php"; // Copyright (c) 2003 by Art Cancro // This program is released under the terms of the GNU General Public License. +global $msgsock; // sock_gets() -- reads one line of text from a socket // -$msgsock; if (CITADEL_DEBUG_PROXY) { define_syslog_variables(); @@ -96,7 +96,7 @@ chmod($sockname, 0600); // We need to get a connection to the Citadel server going now. -$ctdlsock = fsockopen(SOCKET_PREFIX.CITADEL_HOSTNAME, CITADEL_TCP_PORTNO, $errno, $errstr, 30); +$ctdlsock = fsockopen(CITADEL_HOSTNAME, CITADEL_TCP_PORTNO, $errno, $errstr, 30); if (!$ctdlsock) { socket_close ($sock); system("/bin/rm -f " . $sockname); -- 2.30.2