| 1 |
<?php |
<?php |
| 2 |
// $Id: services_keyauth.inc,v 1.1.2.8.2.5 2009/10/31 20:58:11 heyrocker Exp $ |
// $Id: services_keyauth.inc,v 1.1.2.8.2.6 2009/11/02 19:42:33 heyrocker Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 84 |
|
|
| 85 |
foreach ($methods as $key => &$method) { |
foreach ($methods as $key => &$method) { |
| 86 |
// set method defaults |
// set method defaults |
| 87 |
switch ($method['#method']) { |
switch ($method['method']) { |
| 88 |
case 'system.connect': |
case 'system.connect': |
| 89 |
$method['#key'] = FALSE; |
$method['key'] = FALSE; |
| 90 |
$method['#auth'] = FALSE; |
$method['auth'] = FALSE; |
| 91 |
break; |
break; |
| 92 |
default: |
default: |
| 93 |
$method['#key'] = TRUE; |
$method['key'] = TRUE; |
| 94 |
$method['#auth'] = TRUE; |
$method['auth'] = TRUE; |
| 95 |
} |
} |
| 96 |
|
|
| 97 |
if ($method['#auth'] && variable_get('services_use_sessid', TRUE)) { |
if ($method['auth'] && variable_get('services_use_sessid', TRUE)) { |
| 98 |
array_unshift($method['#args'], $arg_sessid); |
array_unshift($method['args'], $arg_sessid); |
| 99 |
} |
} |
| 100 |
|
|
| 101 |
if ($method['#key'] && variable_get('services_use_key', TRUE)) { |
if ($method['key'] && variable_get('services_use_key', TRUE)) { |
| 102 |
array_unshift($method['#args'], $arg_nonce); |
array_unshift($method['args'], $arg_nonce); |
| 103 |
array_unshift($method['#args'], $arg_domain_time_stamp); |
array_unshift($method['args'], $arg_domain_time_stamp); |
| 104 |
array_unshift($method['#args'], $arg_domain_name); |
array_unshift($method['args'], $arg_domain_name); |
| 105 |
array_unshift($method['#args'], $arg_api_key); |
array_unshift($method['args'], $arg_api_key); |
| 106 |
} |
} |
| 107 |
} |
} |
| 108 |
} |
} |
| 109 |
|
|
| 110 |
function _services_keyauth_alter_browse_form(&$form, $method) { |
function _services_keyauth_alter_browse_form(&$form, $method) { |
| 111 |
|
|
| 112 |
foreach ($method['#args'] as $key => $arg) { |
foreach ($method['args'] as $key => $arg) { |
| 113 |
switch ($arg['#name']) { |
switch ($arg['name']) { |
| 114 |
case 'hash': |
case 'hash': |
| 115 |
$form['arg'][$key] = array( |
$form['arg'][$key] = array( |
| 116 |
'#title' => 'Hash', |
'#title' => 'Hash', |
| 141 |
} |
} |
| 142 |
|
|
| 143 |
function _services_keyauth_authenticate_call($method, $method_name, &$args) { |
function _services_keyauth_authenticate_call($method, $method_name, &$args) { |
| 144 |
if ($method['#key'] && variable_get('services_use_key', TRUE)) { |
if ($method['key'] && variable_get('services_use_key', TRUE)) { |
| 145 |
$hash = array_shift($args); |
$hash = array_shift($args); |
| 146 |
$domain = array_shift($args); |
$domain = array_shift($args); |
| 147 |
$timestamp = array_shift($args); |
$timestamp = array_shift($args); |
| 179 |
|
|
| 180 |
// Add additonal processing for methods requiring session |
// Add additonal processing for methods requiring session |
| 181 |
$session_backup = NULL; |
$session_backup = NULL; |
| 182 |
if ($method['#auth'] && variable_get('services_use_sessid', TRUE)) { |
if ($method['auth'] && variable_get('services_use_sessid', TRUE)) { |
| 183 |
$sessid = array_shift($args); |
$sessid = array_shift($args); |
| 184 |
if (empty($sessid)) { |
if (empty($sessid)) { |
| 185 |
return t('Invalid sessid.'); |
return t('Invalid sessid.'); |
| 189 |
} |
} |
| 190 |
|
|
| 191 |
function _services_keyauth_alter_browse_form_submit($method, &$args) { |
function _services_keyauth_alter_browse_form_submit($method, &$args) { |
| 192 |
if ($method['#key'] && variable_get('services_use_key', TRUE)) { |
if ($method['key'] && variable_get('services_use_key', TRUE)) { |
| 193 |
$args_stripped = $args; |
$args_stripped = $args; |
| 194 |
|
|
| 195 |
for ($i = 1; $i <= 4; $i++) { |
for ($i = 1; $i <= 4; $i++) { |