brute-force changed access to $_GET['key'] to use get_array instead
[plewww.git] / planetlab / slices / test.php
1 <?php
2
3 // $Id$
4
5   // *NOTE*
6   // the optimization done for nodes was *not* merged here, because of the following bug
7
8   //root@onelab-private /tmp # api
9   //PlanetLab Central Direct API Access
10   //Type "system.listMethods()" or "help(method)" for more information.
11   //>>> GetSlices({'name':'o*','~expires':0})
12   //Database error 52cfdd40-b57e-43cb-ace0-406d49408527:
13   //unindexable object
14   //Query:
15   //SELECT creator_person_id, instantiation, slice_tag_ids, name, slice_id, created, url, max_nodes, person_ids, expires, site_id, peer_slice_id, node_ids, peer_id, description FROM view_slices WHERE is_deleted IS False AND expires > 1175085968 AND (True AND name LIKE 'o%' AND  ( NOT expires = 0 ) )
16   //Params:
17   //{'api': <PLC.API.PLCAPI instance at 0xb7b466ac>,
18   // 'columns': None,
19   // 'expires': 1175085968,
20   // 'self': [],
21   // 'slice_filter': {'creator_person_id': (<type 'int'>, [<type 'int'>]), 'instantiation': (<type 'str'>, [<type 'str'>]), 'name': (<type 'str'>, [<type 'str'>]), 'slice_id': (<type 'int'>, [<type 'int'>]), 'created': (<type 'int'>, [<type 'int'>]), 'url': (<type 'str'>, [<type 'str'>]), 'max_nodes': (<type 'int'>, [<type 'int'>]), 'expires': (<type 'int'>, [<type 'int'>]), 'site_id': (<type 'int'>, [<type 'int'>]), 'peer_slice_id': (<type 'int'>, [<type 'int'>]), 'peer_id': (<type 'int'>, [<type 'int'>]), 'description': (<type 'str'>, [<type 'str'>])},
22   // 'sql': "SELECT creator_person_id, instantiation, slice_tag_ids, name, slice_id, created, url, max_nodes, person_ids, expires, site_id, peer_slice_id, node_ids, peer_id, description FROM view_slices WHERE is_deleted IS False AND expires > 1175085968 AND (True AND name LIKE 'o%' AND  ( NOT expires = 0 ) )"}
23   //Traceback (most recent call last):
24   //  File "/usr/bin/plcsh", line 139, in ?
25   //    result = eval(command)
26   //  File "<string>", line 0, in ?
27   //  File "/usr/share/plc_api/PLC/Shell.py", line 51, in __call__
28   //    return self.func(*args, **kwds)
29   //  File "/usr/share/plc_api/PLC/Method.py", line 105, in __call__
30   //    raise fault
31   //PLCDBError: <Fault 106: 'GetSlices: Database error: Please contact OneLabPrivate Support <support@one-lab.org> and reference 52cfdd40-b57e-43cb-ace0-406d49408527'>
32
33 // Get session and API handles
34 require_once 'plc_session.php';
35 global $plc, $api, $adm;
36
37
38 $arr= $adm->GetSlices( NULL, array( "name" ) );
39
40 foreach( $arr as $slices ) {
41   $useArr[]= $slices['name'];
42 }
43
44
45 $input = strtolower( get_array($_GET, 'input') );
46 $len = strlen($input);
47
48 $aResults = array();
49
50 if ($len) {
51   for ( $i=0; $i<count($useArr); $i++ ) {
52     if ( strtolower( substr( $useArr[$i], 0, $len ) ) == $input )
53       $aResults[] = $useArr[$i];
54   }
55 }
56
57
58 header("Content-Type: text/xml");
59
60 echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>
61 <results>";
62 for ( $i=0; $i<count($aResults); $i++ )
63   echo" <rs>". $aResults[$i] ."</rs>";
64
65 echo "
66 </results>
67 ";
68
69 ?>