00001 <?php 00002 /*!*************************************************************************** 00003 *! FILE NAME : paramtool.php 00004 *! DESCRIPTION: wrapper for Axis bootblocktool 00005 *! (the original CGI mode uses non-standard parameters and fails with lighttpd) 00006 *! only 2 commands "-l" and "-w" 00007 *! Copyright (C) 2008 Elphel, Inc 00008 *! -----------------------------------------------------------------------------** 00009 *! 00010 *! This program is free software: you can redistribute it and/or modify 00011 *! it under the terms of the GNU General Public License as published by 00012 *! the Free Software Foundation, either version 3 of the License, or 00013 *! (at your option) any later version. 00014 *! 00015 *! This program is distributed in the hope that it will be useful, 00016 *! but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 *! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 *! GNU General Public License for more details. 00019 *! 00020 *! You should have received a copy of the GNU General Public License 00021 *! along with this program. If not, see <http://www.gnu.org/licenses/>. 00022 *! -----------------------------------------------------------------------------** 00023 *! $Log: paramtool.php,v $ 00024 *! Revision 1.1.1.1 2008/11/27 20:04:03 elphel 00025 *! 00026 *! 00027 *! Revision 1.1 2008/03/15 18:39:33 elphel 00028 *! new wrapper for Axis bootblocktool - old CGI mode used non-standard parameters and did not work with lighttpd 00029 *! 00030 *! 00031 */ 00032 00033 $pgm_name="bootblocktool"; 00034 if (count($_GET) > 0 ) { 00035 $cmd=$pgm_name." -w "; 00036 $pars=array(); 00037 foreach($_GET as $key=>$value) { 00038 $cmd.= $key."=".$value.":"; 00039 } 00040 $cmd=rtrim($cmd,":"); 00041 exec ($cmd); 00042 } 00043 $cmd=$pgm_name." -l"; 00044 $arslt=array(); 00045 $outp= exec ($cmd, &$arslt); 00046 $xml = new SimpleXMLElement("<?xml version='1.0' standalone='yes'?><bootblock/>"); 00047 foreach ($arslt as $val) { 00048 $kv = explode("=", $val); 00049 $xml->addChild ($kv[0],$kv[1]); 00050 } 00051 $rslt=$xml->asXML(); 00052 header("Content-Type: text/xml"); 00053 header("Content-Length: ".strlen($rslt)."\n"); 00054 header("Pragma: no-cache\n"); 00055 printf($rslt); 00056 ?>