4398f242a208ecd2450fd383b77efb85bff78608
[plewww.git] / planetlab / sites / test.php
1 <?php
2
3 // $Id: test.php 162 2007-03-29 07:18:49Z thierry $
4
5 // Get session and API handles
6 require_once 'plc_session.php';
7 global $plc, $api, $adm;
8
9 // input 
10 $input = $_GET['input'];
11 $len = strlen($input);
12
13 // init result
14 $aResults = array();
15
16 // dont query the db on empty input
17 if ($len) {
18   // query db
19   $input .= "%";
20   $sites= $adm->GetSites( array( "name" => $input ), array("name") );
21   if (count($sites)) {
22     foreach ( $sites as $site ) {
23       $aResults[] = $site['name'];
24     }
25   }
26 }
27
28 header("Content-Type: text/xml");
29
30 echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>
31 <results>";
32 for ($i=0;$i<count($aResults);$i++)
33   echo" <rs>".$aResults[$i]."</rs>";
34
35 echo "
36 </results>
37 ";
38
39 ?>