| 1 |
<?php |
<?php |
| 2 |
// $Id: services_admin_browse.inc,v 1.5.2.12 2008/08/29 10:15:16 brmassa Exp $ |
// $Id: services_admin_browse.inc,v 1.5.2.13 2008/08/29 10:19:05 brmassa Exp $ |
| 3 |
/** |
/** |
| 4 |
* @author Services Dev Team |
* @author Services Dev Team |
| 5 |
* @file |
* @file |
| 104 |
$form['optional'][$key] = array('#value' => ($arg['#optional']) ? t('optional') : t('required')); |
$form['optional'][$key] = array('#value' => ($arg['#optional']) ? t('optional') : t('required')); |
| 105 |
|
|
| 106 |
switch ($arg['#name']) { |
switch ($arg['#name']) { |
| 107 |
case 'api_key': |
case 'hash': |
| 108 |
$form['arg'][$key] = array('#type' => 'textfield', '#default_value' => services_admin_browse_get_first_key()); |
$form['arg'][$key] = array('#title' => 'Hash', '#type' => 'textfield', '#default_value' => hash_hmac("sha256", $timestamp . $_SERVER['HTTP_HOST'] . $nonce . arg(4), services_admin_browse_get_first_key())); |
| 109 |
break; |
break; |
| 110 |
|
|
| 111 |
case 'sessid': |
case 'sessid': |
| 112 |
$form['arg'][$key] = array('#type' => 'textfield', '#default_value' => session_id()); |
$form['arg'][$key] = array('#title' => 'Session id', '#type' => 'textfield', '#default_value' => session_id()); |
| 113 |
break; |
break; |
| 114 |
|
|
| 115 |
case 'domain_check': |
case 'domain_name': |
| 116 |
$form['arg'][$key] = array('#type' => 'textfield', '#default_value' => $_SERVER['HTTP_HOST']); |
$form['arg'][$key] = array('#title' => 'Domain name','#type' => 'textfield', '#default_value' => $_SERVER['HTTP_HOST']); |
| 117 |
break; |
break; |
| 118 |
|
|
| 119 |
case 'domain_time_stamp': |
case 'domain_time_stamp': |
| 120 |
$form['arg'][$key] = array('#type' => 'textfield', '#default_value' => time()); |
$form['arg'][$key] = array('#title' => 'Timestamp', '#type' => 'textfield', '#default_value' => $timestamp); |
| 121 |
|
break; |
| 122 |
|
|
| 123 |
|
case 'nonce': |
| 124 |
|
$form['arg'][$key] = array('#title' => 'Nonce', '#type' => 'textfield', '#default_value' => $nonce); |
| 125 |
break; |
break; |
| 126 |
|
|
| 127 |
default: |
default: |
| 194 |
$rows = array(); |
$rows = array(); |
| 195 |
foreach (element_children($form['name']) as $key => $type) { |
foreach (element_children($form['name']) as $key => $type) { |
| 196 |
$row = array(); |
$row = array(); |
| 197 |
$row[] = drupal_render($form['name'][$key]); |
if (isset($form['arg'][$key]['#title'])) { |
| 198 |
|
$row[] = $form['arg'][$key]['#title']; |
| 199 |
|
unset($form['arg'][$key]['#title']); |
| 200 |
|
unset($form['name'][$key]); |
| 201 |
|
} |
| 202 |
|
else { |
| 203 |
|
$row[] = drupal_render($form['name'][$key]); |
| 204 |
|
} |
| 205 |
$row[] = drupal_render($form['optional'][$key]); |
$row[] = drupal_render($form['optional'][$key]); |
| 206 |
$row[] = drupal_render($form['arg'][$key]); |
$row[] = drupal_render($form['arg'][$key]); |
| 207 |
$rows[] = $row; |
$rows[] = $row; |
| 230 |
'#type' => 'checkbox', |
'#type' => 'checkbox', |
| 231 |
'#title' => t('Use keys'), |
'#title' => t('Use keys'), |
| 232 |
'#default_value' => variable_get('services_use_key', TRUE), |
'#default_value' => variable_get('services_use_key', TRUE), |
| 233 |
'#description' => t('When enabled, all method calls must include a valid key.') |
'#description' => t('When enabled all method calls need to provide a validation token to autheciate themselves with the server.'), |
| 234 |
); |
); |
| 235 |
$form['security']['services_domain_strict'] = array( |
$form['security']['services_key_expiry'] = array( |
| 236 |
'#type' => 'checkbox', |
'#type' => 'textfield', |
| 237 |
'#title' => t('Strict domain checking'), |
'#prefix' => "<div id='services-key-expiry'>", |
| 238 |
'#default_value' => variable_get('services_domain_strict', FALSE), |
'#suffix' => "</div>", |
| 239 |
'#description' => t('When enabled, all method calls must include their domain to validate against the key.') |
'#title' => t('Token expiry time'), |
| 240 |
|
'#default_value' => variable_get('services_key_expiry', 30), |
| 241 |
|
'#description' => t('The time frame for which the token will be valid. Default is 30 secs'), |
| 242 |
); |
); |
| 243 |
$form['security']['services_use_sessid'] = array( |
$form['security']['services_use_sessid'] = array( |
| 244 |
'#type' => 'checkbox', |
'#type' => 'checkbox', |
| 247 |
'#description' => t('When enabled, all method calls must include a valid sessid. Only disable this setting if the application will user browser-based cookies.') |
'#description' => t('When enabled, all method calls must include a valid sessid. Only disable this setting if the application will user browser-based cookies.') |
| 248 |
); |
); |
| 249 |
|
|
| 250 |
$form['debug'] = array( |
services_admin_js($form); |
|
'#title' => t('Debugging'), |
|
|
'#type' => 'fieldset', |
|
|
); |
|
|
$form['debug']['services_debug'] = array( |
|
|
'#type' => 'checkbox', |
|
|
'#title' => t('Enable debug mode'), |
|
|
'#default_value' => variable_get('services_debug', TRUE), |
|
|
'#description' => t('When enabled, debugging features will be enabled.') |
|
|
); |
|
| 251 |
|
|
| 252 |
return system_settings_form($form); |
return system_settings_form($form); |
| 253 |
} |
} |
| 254 |
|
|
| 255 |
|
/** |
| 256 |
|
* UI enhancement for services page |
| 257 |
|
*/ |
| 258 |
|
function services_admin_js($form) { |
| 259 |
|
$out = <<<EOJS |
| 260 |
|
$(document).ready(function() { |
| 261 |
|
$("#services-key-expiry")[$("#edit-services-use-key").attr('checked') ? 'show' : 'hide'](); |
| 262 |
|
$("#edit-services-use-key").click(function() { |
| 263 |
|
$("#services-key-expiry")[$(this).attr('checked') ? 'show' : 'hide'](); |
| 264 |
|
}); |
| 265 |
|
}); |
| 266 |
|
EOJS; |
| 267 |
|
drupal_add_js($out, 'inline', 'footer'); |
| 268 |
|
} |