| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
$Id: gateway.php,v 1.4 2005/07/05 07:40:54 pmineault Exp $ |
|---|
| 4 |
|
|---|
| 5 |
The gateway is a customized entry point to your flash |
|---|
| 6 |
services. |
|---|
| 7 |
|
|---|
| 8 |
Things you can set here: |
|---|
| 9 |
|
|---|
| 10 |
- setBaseClassPath(string path) The absolute path to your services on the server |
|---|
| 11 |
|
|---|
| 12 |
- setLooseMode(bool mode) If true, output buffering is enabled and error_reporting |
|---|
| 13 |
is lowered to circumvent a number of documented NetConnection.BadVersion errors |
|---|
| 14 |
|
|---|
| 15 |
- setCharsetHandler(string mode, string phpCharset, string sqlCharset) |
|---|
| 16 |
|
|---|
| 17 |
mode can be one of |
|---|
| 18 |
- none don't do anything |
|---|
| 19 |
- iconv uses the iconv libray for reencoding |
|---|
| 20 |
- mbstring uses the mbstring library for reencoding |
|---|
| 21 |
- recode uses the recode library for reencoding |
|---|
| 22 |
- utf8_decode uses the XML function utf8_decode and encode for |
|---|
| 23 |
reencoding - ISO-8859-1 only |
|---|
| 24 |
|
|---|
| 25 |
phpCharset is the charset that the system assumes the PHP strings will be in. |
|---|
| 26 |
|
|---|
| 27 |
sqlCharset is the charset of sql result sets used (only when outputting results |
|---|
| 28 |
to flash client) |
|---|
| 29 |
|
|---|
| 30 |
wsCharset (web service charset) has been eliminated from this release, UTF-8 |
|---|
| 31 |
is assumed as the remote encoding. When using PHP5 SoapClient, the SoapClient |
|---|
| 32 |
object will be initialized with "encoding" => phpCharset. When using nusoap, |
|---|
| 33 |
soapclient->soap_defencoding will be initialized with phpCharset. |
|---|
| 34 |
|
|---|
| 35 |
The following settings are recommended (try the first setting appropriate for |
|---|
| 36 |
your language, if it doesn't work try the second): |
|---|
| 37 |
|
|---|
| 38 |
* English: |
|---|
| 39 |
|
|---|
| 40 |
$gateway->setCharsetHandler( "none", "ISO-8859-1", "ISO-8859-1" ); |
|---|
| 41 |
|
|---|
| 42 |
* Western european languages (French, Spanish, German, etc.): |
|---|
| 43 |
|
|---|
| 44 |
$gateway->setCharsetHandler( "iconv", "ISO-8859-1", "ISO-8859-1" ); |
|---|
| 45 |
$gateway->setCharsetHandler( "utf8_decode", "ISO-8859-1", "ISO-8859-1" ); |
|---|
| 46 |
|
|---|
| 47 |
* Eastern european languages (Russian and other slavic languages): |
|---|
| 48 |
|
|---|
| 49 |
$gateway->setCharsetHandler( "none", "ISO-8859-1", "ISO-8859-1" ); |
|---|
| 50 |
$gateway->setCharsetHandler( "iconv", "your codepage", "your codepage" ); |
|---|
| 51 |
|
|---|
| 52 |
* Oriental languages (Chinese, japanese, korean): |
|---|
| 53 |
|
|---|
| 54 |
$gateway->setCharsetHandler( "none", "ISO-8859-1", "ISO-8859-1" ); |
|---|
| 55 |
$gateway->setCharsetHandler( "iconv", "big5", "big5" ); |
|---|
| 56 |
$gateway->setCharsetHandler( "iconv", "CP950", "CP950" ); |
|---|
| 57 |
$gateway->setCharsetHandler( "iconv", "Shift_JIS", "Shift_JIS" ); |
|---|
| 58 |
$gateway->setCharsetHandler( "iconv", "CP932", "CP932" ); |
|---|
| 59 |
$gateway->setCharsetHandler( "iconv", "CP949", "CP949" ); |
|---|
| 60 |
|
|---|
| 61 |
* Other languages: |
|---|
| 62 |
|
|---|
| 63 |
$gateway->setCharsetHandler( "none", "ISO-8859-1", "ISO-8859-1" ); |
|---|
| 64 |
|
|---|
| 65 |
See all the possible codepages for iconv here: |
|---|
| 66 |
|
|---|
| 67 |
http://www.gnu.org/software/libiconv/ |
|---|
| 68 |
|
|---|
| 69 |
iconv is included by default in php5, but not in php4 although most |
|---|
| 70 |
hosts have it installed. utf8_decode is of some use for Western European languages, |
|---|
| 71 |
but please remember that it won't work with settings other than ISO-8859-1. |
|---|
| 72 |
The other methods also require seldom-used extensions but were included |
|---|
| 73 |
just in case your particular host only supports them. |
|---|
| 74 |
|
|---|
| 75 |
- setWebServiceHandler(string handler) |
|---|
| 76 |
Handler can be one of: |
|---|
| 77 |
- php5 (that is, PHP5 SoapClient) |
|---|
| 78 |
- pear |
|---|
| 79 |
- nusoap |
|---|
| 80 |
This is used for webservices when working with http:// service names in |
|---|
| 81 |
new Service(). For php5 and pear, you will need to have it installed on your |
|---|
| 82 |
server. For nusoap, you need nusoap.php instead in ./lib relative to this file. |
|---|
| 83 |
|
|---|
| 84 |
If you have PHP5 and the SOAP extension installed it is highly recommended that |
|---|
| 85 |
you use it as it is _much_ faster than NuSOAP or PEAR::SOAP |
|---|
| 86 |
|
|---|
| 87 |
Things you may want to disable for production environments: |
|---|
| 88 |
|
|---|
| 89 |
- disableStandalonePlayer() |
|---|
| 90 |
Disables the standalone player by filtering out its User-Agent string |
|---|
| 91 |
|
|---|
| 92 |
- disableServiceDescription() |
|---|
| 93 |
Disable service description from Macromedia's service browser |
|---|
| 94 |
|
|---|
| 95 |
- disableTrace() |
|---|
| 96 |
Disables remote tracing |
|---|
| 97 |
|
|---|
| 98 |
- disableDebug() |
|---|
| 99 |
Stops debug info from being sent (independant of remote trace setting) |
|---|
| 100 |
|
|---|
| 101 |
*/ |
|---|
| 102 |
|
|---|
| 103 |
include "amf-core/app/Gateway.php"; |
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
//You will also have the constant available in your classes, for changing |
|---|
| 107 |
//the mysql server info for example |
|---|
| 108 |
define("PRODUCTION_SERVER", false); |
|---|
| 109 |
|
|---|
| 110 |
$gateway = new Gateway(); |
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
$gateway->setBaseClassPath("services/"); |
|---|
| 114 |
|
|---|
| 115 |
|
|---|
| 116 |
$gateway->setLooseMode(true); |
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 |
//The main contributor (Patrick Mineault) is French, |
|---|
| 120 |
//so don't be afraid if he forgot to turn off iconv by default! |
|---|
| 121 |
//$gateway->setCharsetHandler("utf8_decode", "ISO-8859-1", "ISO-8859-1"); |
|---|
| 122 |
|
|---|
| 123 |
//Error types that will be rooted to the NetConnection debugger |
|---|
| 124 |
$gateway->setErrorHandling(E_ALL ^ E_NOTICE); |
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 |
//If you don't plan on using web services with AMFPHP, |
|---|
| 128 |
//you can safely let this setting alone |
|---|
| 129 |
//Note that for nusoap to work you MUST place the library under /amf-core/lib/nusoap.php |
|---|
| 130 |
$gateway->setWebServiceHandler('php5'); |
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 |
//and mapped in adapters/%adapterName%Adapter.php. This works by using get_class |
|---|
| 134 |
//So for example, if you return a PEAR resultset object, it is an instance of DB_result |
|---|
| 135 |
//And we want this to be processed as a recordset in adapters/peardbAdapter.php, |
|---|
| 136 |
//hence the following line: |
|---|
| 137 |
$gateway->addAdapterMapping('db_result', 'peardb'); |
|---|
| 138 |
|
|---|
| 139 |
$gateway->addAdapterMapping('pdostatement', 'pdo'); |
|---|
| 140 |
|
|---|
| 141 |
$gateway->addAdapterMapping('mysqli_result', 'mysqli'); |
|---|
| 142 |
|
|---|
| 143 |
//And for filtered typed array (see adapters/lib/Arrayf.php and Arrayft.php) |
|---|
| 144 |
$gateway->addAdapterMapping('arrayf', 'arrayf'); |
|---|
| 145 |
$gateway->addAdapterMapping('arrayft', 'arrayft'); |
|---|
| 146 |
|
|---|
| 147 |
|
|---|
| 148 |
if(PRODUCTION_SERVER) |
|---|
| 149 |
{ |
|---|
| 150 |
|
|---|
| 151 |
$gateway->disableTrace(); |
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 |
$gateway->disableDebug(); |
|---|
| 155 |
|
|---|
| 156 |
|
|---|
| 157 |
$gateway->disableServiceDescription(); |
|---|
| 158 |
} |
|---|
| 159 |
|
|---|
| 160 |
|
|---|
| 161 |
//the like, you can add $gateway->logIncomingMessages('path/to/incoming/messages/'); |
|---|
| 162 |
//and $gateway->logOutgoingMessages('path/to/outgoing/messages/'); here |
|---|
| 163 |
|
|---|
| 164 |
//If using under SSL (https) with IE6, usually the default amfphp method will |
|---|
| 165 |
//work. It is however possible that it doesn't, in which case, enable the |
|---|
| 166 |
//second SSL method, and apply the patch described here: |
|---|
| 167 |
//http://www.gmrweb.net/2005/08/18/flash-remoting-https-internet-explorer/ |
|---|
| 168 |
//(requires mod_headers) |
|---|
| 169 |
//$gateway->useSslSecondMethod(); |
|---|
| 170 |
|
|---|
| 171 |
//This is new to AMFPHP 1.2: |
|---|
| 172 |
//Set custom class mappings (kept in a second config file for convenience) |
|---|
| 173 |
include_once('advancedsettings.php'); |
|---|
| 174 |
|
|---|
| 175 |
|
|---|
| 176 |
$gateway->service(); |
|---|
| 177 |
|
|---|
| 178 |
?> |
|---|