5 Modification information for LGPL compliance
7 r57813 - 2010-08-19 10:34:44 -0700 (Thu, 19 Aug 2010) - kjing - Author: John Mertic <jmertic@sugarcrm.com>
8 Bug 39085 - When loading the opposite search panel via ajax on the ListViews, call the index action instead of the ListView action to avoid touching pre-MVC code by accident.
10 r56990 - 2010-06-16 13:05:36 -0700 (Wed, 16 Jun 2010) - kjing - snapshot "Mango" svn branch to a new one for GitHub sync
12 r56989 - 2010-06-16 13:01:33 -0700 (Wed, 16 Jun 2010) - kjing - defunt "Mango" svn dev branch before github cutover
14 r55980 - 2010-04-19 13:31:28 -0700 (Mon, 19 Apr 2010) - kjing - create Mango (6.1) based on windex
16 r51719 - 2009-10-22 10:18:00 -0700 (Thu, 22 Oct 2009) - mitani - Converted to Build 3 tags and updated the build system
18 r51634 - 2009-10-19 13:32:22 -0700 (Mon, 19 Oct 2009) - mitani - Windex is the branch for Sugar Sales 1.0 development
20 r50375 - 2009-08-24 18:07:43 -0700 (Mon, 24 Aug 2009) - dwong - branch kobe2 from tokyo r50372
22 r42807 - 2008-12-29 11:16:59 -0800 (Mon, 29 Dec 2008) - dwong - Branch from trunk/sugarcrm r42806 to branches/tokyo/sugarcrm
24 r13782 - 2006-06-06 10:58:55 -0700 (Tue, 06 Jun 2006) - majed - changes entry point code
26 r11115 - 2006-01-17 14:54:45 -0800 (Tue, 17 Jan 2006) - majed - add entry point validation
28 r8846 - 2005-10-31 11:01:12 -0800 (Mon, 31 Oct 2005) - majed - new version of nusoap
30 r5462 - 2005-05-25 13:50:11 -0700 (Wed, 25 May 2005) - majed - upgraded nusoap to .6.9
32 r573 - 2004-09-04 13:03:32 -0700 (Sat, 04 Sep 2004) - sugarclint - undoing copyrights added in inadvertantly. --clint
34 r546 - 2004-09-03 11:49:38 -0700 (Fri, 03 Sep 2004) - sugarmsi - removed echo count
36 r354 - 2004-08-02 23:00:37 -0700 (Mon, 02 Aug 2004) - sugarjacob - Adding Soap
42 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
45 The NuSOAP project home is:
46 http://sourceforge.net/projects/nusoap/
48 The primary support for NuSOAP is the mailing list:
49 nusoap-general@lists.sourceforge.net
53 * caches instances of the wsdl class
55 * @author Scott Nichol <snichol@users.sourceforge.net>
56 * @author Ingo Fischer <ingo@apollon.de>
60 class nusoap_wsdlcache {
85 * @param string $cache_dir directory for cache-files
86 * @param integer $cache_lifetime lifetime for caching-files in seconds or 0 for unlimited
89 function nusoap_wsdlcache($cache_dir='.', $cache_lifetime=0) {
90 $this->fplock = array();
91 $this->cache_dir = $cache_dir != '' ? $cache_dir : '.';
92 $this->cache_lifetime = $cache_lifetime;
96 * creates the filename used to cache a wsdl instance
98 * @param string $wsdl The URL of the wsdl instance
99 * @return string The filename used to cache the instance
102 function createFilename($wsdl) {
103 return $this->cache_dir.'/wsdlcache-' . md5($wsdl);
107 * adds debug data to the class level debug string
109 * @param string $string debug data
112 function debug($string){
113 $this->debug_str .= get_class($this).": $string\n";
117 * gets a wsdl instance from the cache
119 * @param string $wsdl The URL of the wsdl instance
120 * @return object wsdl The cached wsdl instance, null if the instance is not in the cache
123 function get($wsdl) {
124 $filename = $this->createFilename($wsdl);
125 if ($this->obtainMutex($filename, "r")) {
126 // check for expired WSDL that must be removed from the cache
127 if ($this->cache_lifetime > 0) {
128 if (file_exists($filename) && (time() - filemtime($filename) > $this->cache_lifetime)) {
130 $this->debug("Expired $wsdl ($filename) from cache");
131 $this->releaseMutex($filename);
135 // see what there is to return
136 if (!file_exists($filename)) {
137 $this->debug("$wsdl ($filename) not in cache (1)");
138 $this->releaseMutex($filename);
141 $fp = @fopen($filename, "r");
143 $s = implode("", @file($filename));
145 $this->debug("Got $wsdl ($filename) from cache");
148 $this->debug("$wsdl ($filename) not in cache (2)");
150 $this->releaseMutex($filename);
151 return (!is_null($s)) ? unserialize($s) : null;
153 $this->debug("Unable to obtain mutex for $filename in get");
159 * obtains the local mutex
161 * @param string $filename The Filename of the Cache to lock
162 * @param string $mode The open-mode ("r" or "w") or the file - affects lock-mode
163 * @return boolean Lock successfully obtained ?!
166 function obtainMutex($filename, $mode) {
167 if (isset($this->fplock[md5($filename)])) {
168 $this->debug("Lock for $filename already exists");
171 $this->fplock[md5($filename)] = fopen($filename.".lock", "w");
173 return flock($this->fplock[md5($filename)], LOCK_SH);
175 return flock($this->fplock[md5($filename)], LOCK_EX);
180 * adds a wsdl instance to the cache
182 * @param object wsdl $wsdl_instance The wsdl instance to add
183 * @return boolean WSDL successfully cached
186 function put($wsdl_instance) {
187 $filename = $this->createFilename($wsdl_instance->wsdl);
188 $s = serialize($wsdl_instance);
189 if ($this->obtainMutex($filename, "w")) {
190 $fp = fopen($filename, "w");
192 $this->debug("Cannot write $wsdl_instance->wsdl ($filename) in cache");
193 $this->releaseMutex($filename);
198 $this->debug("Put $wsdl_instance->wsdl ($filename) in cache");
199 $this->releaseMutex($filename);
202 $this->debug("Unable to obtain mutex for $filename in put");
208 * releases the local mutex
210 * @param string $filename The Filename of the Cache to lock
211 * @return boolean Lock successfully released
214 function releaseMutex($filename) {
215 $ret = flock($this->fplock[md5($filename)], LOCK_UN);
216 fclose($this->fplock[md5($filename)]);
217 unset($this->fplock[md5($filename)]);
219 $this->debug("Not able to release lock for $filename");
225 * removes a wsdl instance from the cache
227 * @param string $wsdl The URL of the wsdl instance
228 * @return boolean Whether there was an instance to remove
231 function remove($wsdl) {
232 $filename = $this->createFilename($wsdl);
233 if (!file_exists($filename)) {
234 $this->debug("$wsdl ($filename) not in cache to be removed");
237 // ignore errors obtaining mutex
238 $this->obtainMutex($filename, "w");
239 $ret = unlink($filename);
240 $this->debug("Removed ($ret) $wsdl ($filename) from cache");
241 $this->releaseMutex($filename);
247 * For backward compatibility
249 class wsdlcache extends nusoap_wsdlcache {