Ignore:
Timestamp:
Jun 9, 2014, 7:11:17 PM (10 years ago)
Author:
mistic100
Message:

update for 2.7

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/skeleton/trunk/include/ws_functions.inc.php

    r26137 r28650  
    55{
    66  $service = &$arr[0];
    7  
     7
     8  // only the first two parameters are mandatory
    89  $service->addMethod(
    9     'pwg.PHPinfo',
    10     'ws_php_info',
     10    'pwg.PHPinfo', // method name
     11    'ws_php_info', // linked PHP function
     12    array( // list of parameters
     13      'what' => array(
     14        'default' => 'INFO_ALL', // default value
     15        'info' => 'This parameter has a default value', // parameter description
     16        ),
     17      'ids' => array(
     18        'flags' => WS_PARAM_OPTIONAL|WS_PARAM_FORCE_ARRAY, // flags are WS_PARAM_OPTIONAL, WS_PARAM_ACCEPT_ARRAY, WS_PARAM_FORCE_ARRAY
     19        'type' => WS_TYPE_INT|WS_TYPE_POSITIVE|WS_TYPE_NOTNULL, // types are WS_TYPE_BOOL, WS_TYPE_INT, WS_TYPE_FLOAT, WS_TYPE_POSITIVE, WS_TYPE_NOTNULL, WS_TYPE_ID
     20        'info' => 'This one must be an array',
     21        ),
     22      'count' => array(
     23        'flags' => WS_PARAM_OPTIONAL,
     24        'type' => WS_TYPE_INT|WS_TYPE_POSITIVE,
     25        'maxValue' => 100, // maximum value for ints and floats
     26        ),
     27      ),
     28    'Returns phpinfo', // method description
     29    null, // file to include after param check and before function exec
    1130    array(
    12       'what' => array('default'=>'INFO_ALL', 'info'=>'This parameter has a default value'),
    13       'ids' => array('flags'=>WS_PARAM_FORCE_ARRAY, 'info'=>'This one must be an array'),
    14       ),
    15     'Returns phpinfo (don\'t use XML request format)',
    16     null,
    17     array('hidden' => false) // you can hide your method from reflection.getMethodList method
     31      'hidden' => false, // you can hide your method from reflection.getMethodList method
     32      'admin_only' => true, // you can restrict access to admins only
     33      'post_only' => false, // you can disallow GET resquests for this method
     34      )
    1835    );
    1936}
     
    2138function ws_php_info($params, &$service)
    2239{
    23   if (!is_admin())
    24   {
    25     return new PwgError(403, 'Forbidden');
    26   }
    27  
    2840  return phpinfo(constant($params['what']));
    2941}
Note: See TracChangeset for help on using the changeset viewer.