43 require_once(
'Cache/Lite.php');
146 if (isset($array[
'defaultCacheGroup'])) {
147 $this->_defaultCacheGroup = $array[
'defaultCacheGroup'];
148 unset($array[
'defaultCacheGroup']);
150 if (isset($array[
'cacheByDefault'])) {
151 $this->_cacheByDefault = $array[
'cacheByDefault'];
152 unset($array[
'CacheByDefault']);
154 $array[
'automaticSerialization'] =
false;
155 if (!isset($array[
'lifetime'])) {
156 $array[
'lifetime'] = 3600;
158 $this->_cacheOptions = $array;
159 $this->_cacheObject =
new Cache_Lite($this->_cacheOptions);
172 if (isset($options[
'cacheOptions'])) {
173 $cacheOptions = $options[
'cacheOptions'];
175 unset($options[
'cacheOptions']);
177 if (isset($options[
'cacheDebug'])) {
178 $this->_cacheDebug = $options[
'cacheDebug'];
179 unset($options[
'cacheDebug']);
181 $this->_options = $options;
182 $this->_callTarget = $callTarget;
183 if (isset($this->_options[
'encoding'])) {
184 $this->_encoding = $this->_options[
'encoding'];
186 if (isset($this->_options[
'prefix'])) {
187 $this->_prefix = $this->_options[
'prefix'];
203 public static function create($callTarget, $options = array())
218 $encoding =
'iso-8859-1';
219 if (isset($this->_options[
'encoding'])) {
220 $encoding = $this->_options[
'encoding'];
222 header(
'Content-type: text/xml; charset=' . $encoding);
234 if (isset(
$GLOBALS[
'HTTP_RAW_POST_DATA'])) {
240 $lifetime = $this->_cacheOptions[
'lifetime'];
241 if ($this->_cacheDebug) {
243 print
"CACHE DEBUG : default values => weCache=true, lifetime=$lifetime\n";
245 print
"CACHE DEBUG : default values => weCache=false, lifetime=$lifetime\n";
251 if ($this->_cacheDebug) {
253 print
"CACHE DEBUG : phpdoc comments => weCache=true, lifetime=$lifetime\n";
255 print
"CACHE DEBUG : phpdoc comments => weCache=false, lifetime=$lifetime\n";
259 if (($weCache) and ($lifetime!=-1)) {
260 if (isset(
$GLOBALS[
'HTTP_RAW_POST_DATA'])) {
263 $cacheId =
'norawpostdata';
265 $this->_cacheObject =
new Cache_Lite($this->_cacheOptions);
266 $this->_cacheObject->setLifetime($lifetime);
267 if (
$data = $this->_cacheObject->get($cacheId, $this->_defaultCacheGroup)) {
269 if ($this->_cacheDebug) {
270 print
"CACHE DEBUG : cache is hit !\n";
274 if ($this->_cacheDebug) {
275 print
"CACHE DEBUG : cache is not hit !\n";
278 $this->_cacheObject->save(
$data);
281 if ($this->_cacheDebug) {
282 print
"CACHE DEBUG : we don't cache !\n";
300 $lifetime = $this->_cacheOptions[
'lifetime'];
301 if (is_string($this->_callTarget)) {
302 $className = strtolower($this->_callTarget);
304 $className = get_class($this->_callTarget);
306 $class =
new ReflectionClass($className);
307 $method = $class->getMethod($methodName);
308 $docs = explode(
"\n",
$method->getDocComment());
309 foreach ($docs as $i => $doc) {
310 $doc = trim($doc,
" \r\t/*");
311 $res = ereg(
'@xmlrpc.caching ([+-]{0,1}[a-zA-Z0-9]*)', $doc,
$results);
314 if (($value==
'yes') or ($value==
'true') or ($value==
'on')) {
316 }
else if (($value==
'no') or ($value==
'false') or ($value==
'off')) {
319 $lifetime = (int) $value;
328 return array($weCache, $lifetime);
345 $res = ereg(
'<methodName>' . $this->_prefix .
'([a-zA-Z0-9\.,\/]*)</methodName>', $request,
$results);
362 require_once(
'XML/RPC2/Server.php');
364 return $this->_serverObject->getResponse();
378 return md5($raw_request . serialize($this->_options));
389 $this->_cacheObject->clean($this->_defaultCacheGroup,
'ingroup');
404 if (extension_loaded(
'mbstring') && (ini_get(
'mbstring.func_overload') & 2) == 2) {
405 $length = mb_strlen($content,
'8bit');
407 $length = strlen((binary)$content);