public
Description: Git mirror of the CMS Made Simple 2.0 rewrite
Homepage: http://cmsmadesimple.org
Clone URL: git://github.com/tedkulp/cmsmadesimple-2-0.git
commit  d5e8a94caf620ce6c3d86ef88e40b47c502ca5a5
tree    2c7f65c765bbd438b4eed235e9a1b765038b48bb
parent  fb6d3e205fb51b37f67afd598e7f8dda4fb27c65
cmsmadesimple-2-0 / soap.php
100644 153 lines (136 sloc) 4.169 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php
#CMS - CMS Made Simple
#(c)2004-2008 by Ted Kulp (ted@cmsmadesimple.org)
#This project's homepage is: http://cmsmadesimple.sf.net
#
#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 2 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 General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#$Id: soap.php 2258 2005-12-03 03:30:54Z wishy $
 
require_once(dirname(__FILE__).'/fileloc.php');
 
function soap_error( $str )
{
  $namespaces = array(
     'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/',
     'xsd' => 'http://www.w3.org/2001/XMLSchema',
     'xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
     'SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/'
     );
  $ns_string = '';
  foreach( $namespaces as $k => $v )
    {
      $ns_string .= "\n xmlns:$k=\"$v\"";
    }
  $txt =
        '<?xml version="1.0" encoding="ISO-8859-1"?>'.
        '<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"'.$ns_string.">\n".
    '<SOAP-ENV:Body>'.
    '<SOAP-ENV:Fault>'.
                '<faultcode>Server</faultcode>'.
   '<faultstring>'.$str.'</faultstring>'.
    '</SOAP-ENV:Fault>'.
    '</SOAP-ENV:Body>'.
  '</SOAP-ENV:Envelope>';
  echo $txt;
}
 
/**
* Entry point for all non-admin pages
*
* @package CMS
*/  
$starttime = microtime();
 
//@ob_start();
 
if (!file_exists(CONFIG_FILE_LOCATION) || filesize(CONFIG_FILE_LOCATION) < 800)
{
    require_once("lib/misc.functions.php");
    redirect("install/install.php");
}
else if (file_exists(TMP_CACHE_LOCATION.'/SITEDOWN'))
{
  header('Content-Type: text/xml');
  echo soap_error('site down for maintenance');
  exit;
}
 
require_once(dirname(__FILE__)."/include.php"); #Makes gCms object
$params = array_merge($_GET, $_POST);
 
if( !isset( $params['module'] ) )
  {
    header('Content-Type: text/xml');
    echo soap_error('missing module parameter');
    exit;
  }
if( !isset( $gCms->modules[$params['module']] ) )
  {
    header('Content-Type: text/xml');
    echo soap_error("module ".$params['module']." not found");
    exit;
  }
 
// this code copied from function.cms_module.php
// then slightly hacked
$cmsmodules = &$gCms->modules;
 
$modresult = '';
if (isset($cmsmodules))
  {
    $modulename = $params['module'];
    
    foreach ($cmsmodules as $key=>$value)
      {
  if (strtolower($modulename) == strtolower($key))
   {
   $modulename = $key;
   }
      }
    
    if (isset($modulename))
      {
  if (isset($cmsmodules[$modulename]))
   {
   if (isset($cmsmodules[$modulename]['object'])
    && $cmsmodules[$modulename]['installed'] == true
    && $cmsmodules[$modulename]['active'] == true
   && $cmsmodules[$modulename]['object']->IsSoapModule())
   {
    //@ob_start();
    $id = 'm' . ++$gCms->variables["modulenum"];
    $params = array_merge($params, GetModuleParameters($id));
    $action = 'soap';
    if (isset($params['action']))
     {
     $action = $params['action'];
     }
    
    $returnid = '';
    if (isset($gCms->variables['pageinfo']) && isset($gCms->variables['pageinfo']->content_id) )
     {
     $returnid = $gCms->variables['pageinfo']->content_id;
     }
    $params['HTTP_RAW_POST_DATA'] = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
    $result = $cmsmodules[$modulename]['object']->DoActionBase($action, $id, $params, $returnid);
    if ($result !== FALSE)
     {
     echo $result;
     }
    $modresult = @ob_get_contents();
    //@ob_end_clean();
   }
   else
   {
    return "<!-- Not a tag module -->\n";
   }
   }
      }
  }
 
// here's the output
echo $modresult;
 
// end of soap stuff
//@ob_flush();
 
$endtime = microtime();
 
# vim:ts=4 sw=4 noet
?>