Hallo Community,
ich habe eine Frage:
Ich habe eine html Datei in welcher ich ein Dropdownmenu mit Filenames anzeigen möchte.
Der Inhalt dieses Menus soll aus dem Returnwert (Array) einer php-Datei eingefügt werden, welche die Filenames bei jedem Aufruf neu ausließt.
mein biesherigen Ansatz:
HTML-Datei:
*******
PHP-Datei:
*********
Ich vermute, dass mein Ansatz nicht korrekt ist und das füllen des Menu´s nicht funktioniert.
Im vorraus vielen Dank für die Hilfe.
ich habe eine Frage:
Ich habe eine html Datei in welcher ich ein Dropdownmenu mit Filenames anzeigen möchte.
Der Inhalt dieses Menus soll aus dem Returnwert (Array) einer php-Datei eingefügt werden, welche die Filenames bei jedem Aufruf neu ausließt.
mein biesherigen Ansatz:
HTML-Datei:
*******
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title> </title> <meta http-equiv="content-type" content="text/html; charset=utf-8"> </head> <body> <div align="center"><table> <tr> <th><form action="host.php"><input type="submit" value="new_Host"></th> <th> <select name="hostname"> foreach($filenames as $value) { echo '<option value="'.$value.'">' .$value. '</option>'; } echo '</select> <input type="submit" value="edit_host" formaction="edit_host.htm" formmethod="post"> <input type="submit" value="delete_host" formaction="delete_host.htm" formmethod="post"> </form> </th> </tr> <tr> <th> <form action="new_host.htm"> <input type="submit" value="new host"></form></th> </tr> </table></div> </body> </html>
PHP-Datei:
*********
PHP-Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title> </title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>
<?php
class Host extends Main
{
private $file;
private $sitename;
private $string;
private $dir;
private $hostname_choice;
private $value;
private $hostgroup();
private $filename = array();
private $filenames = array();
private $hostgroup = array();
private $contagroup = array();
private $i = 0;
private $services = array();
function read_cfg($sitename)
{
$path = "/opt/omd/sites/grn/etc/nagios/conf.d/objects";
$string='host{';
echo "filelist \n ";
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path,FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST); //liefert Array
foreach($it as $file)
{
if($file->isFile())
{
$content = file_get_contents($file);
if (strpos($content, $string) !== false)
{
$filename = new SplFileInfo($file);
$file = $filename->getFilename() //$file = Object with Strings
var_dump($filename->getFilename());
//CODE missing
//file_put_contents(hostfile.txt,$file, FILE_APPEND);
return $filenames;
}
}
}
}
?>
</body>
</html>
Im vorraus vielen Dank für die Hilfe.
Kommentar