| 1 |
<?php
|
| 2 |
// $Id: $
|
| 3 |
|
| 4 |
/*
|
| 5 |
* Implementation of hook_requirements()
|
| 6 |
*/
|
| 7 |
function swx_requirements($phase) {
|
| 8 |
$t = get_t();
|
| 9 |
|
| 10 |
// Test AMFPHP version
|
| 11 |
$requirements['swx'] = array(
|
| 12 |
'title' => $t('SWX PHP'),
|
| 13 |
'value' => $t('1.01'),
|
| 14 |
);
|
| 15 |
|
| 16 |
if (!file_exists(realpath(dirname(__FILE__) . '/server/php/swx.php'))) {
|
| 17 |
$requirements['swx']['value'] = $t('Not found or wrong version');
|
| 18 |
$requirements['swx']['description'] = $t('You must dowload <a href="http://swxformat.org/download/">SWX PHP 1.01</a>, and extract to modules/swx/server.');
|
| 19 |
$requirements['swx']['severity'] = REQUIREMENT_ERROR;
|
| 20 |
}
|
| 21 |
|
| 22 |
return $requirements;
|
| 23 |
}
|
| 24 |
|
| 25 |
/*
|
| 26 |
* Implementation of hook_server_info()
|
| 27 |
*/
|
| 28 |
function swx_server_info() {
|
| 29 |
return array(
|
| 30 |
'#name' => 'SWX PHP',
|
| 31 |
'#path' => 'swx'
|
| 32 |
);
|
| 33 |
}
|
| 34 |
|
| 35 |
|
| 36 |
/*
|
| 37 |
* Implementation of hook_server()
|
| 38 |
*/
|
| 39 |
function swx_server() {
|
| 40 |
_swx_change_dir(FALSE);
|
| 41 |
|
| 42 |
// At least some of these needs to be in the global scope
|
| 43 |
// if we want the SWX server to execute properly
|
| 44 |
global $startTime, $class, $method, $url, $data, $debug, $v, $urlValid, $classNameDisallowedCharacters, $methodNameDisallowedCharacters, $class, $classToLoad, $instance, $method, $allowedMethods, $dataAsPhp, $data, $undefinedArgumentIndices, $numUndefinedArguments, $numArguments, $arguments, $pluralization, $errorMsg, $jsonStartTime, $j, $jsonDuration, $methodStartTime, $result, $methodDuration, $swxGatewayOverhead, $duration, $swxAssemblerStartTime, $swxAssembler, $compressionLevel, $jsonPercentage, $swxAssemblerPercentage, $methodPercentage, $otherPercentage, $allowDomain;
|
| 45 |
require "swx.php"; // Include the SWX server.
|
| 46 |
exit(0);
|
| 47 |
}
|
| 48 |
|
| 49 |
|
| 50 |
/**
|
| 51 |
* Callback for the SWX service
|
| 52 |
*
|
| 53 |
* @param unknown_type $service
|
| 54 |
*/
|
| 55 |
function _swx_call_service($method_name, $args) {
|
| 56 |
_swx_change_dir(TRUE);
|
| 57 |
|
| 58 |
$result = services_method_call($method_name, $args);
|
| 59 |
|
| 60 |
_swx_change_dir(FALSE);
|
| 61 |
|
| 62 |
return $result;
|
| 63 |
}
|
| 64 |
|
| 65 |
|
| 66 |
/**
|
| 67 |
* Switches between the Drupal base directory and the SWX base directory.
|
| 68 |
*/
|
| 69 |
function _swx_change_dir($to_drupal = FALSE) {
|
| 70 |
static $drupal_dir;
|
| 71 |
static $swx_dir;
|
| 72 |
|
| 73 |
if (!isset($drupal_dir)) {
|
| 74 |
$drupal_dir = getcwd();
|
| 75 |
$swx_dir = $drupal_dir . '/' . drupal_get_path('module', 'swx') . '/server/php/';
|
| 76 |
}
|
| 77 |
|
| 78 |
if ($to_drupal) {
|
| 79 |
chdir($drupal_dir);
|
| 80 |
} else {
|
| 81 |
chdir($swx_dir);
|
| 82 |
}
|
| 83 |
}
|