Location: PHPKode > projects > Serveur Multicartes IPX800 > multicardipx800/renseignehelp.php
<?php
require("Head.php");
$edit = false;
if ( isset($_REQUEST["id"]) )
{
	if ( isset($_REQUEST["titre"]) && $_REQUEST["titre"] != "" && $_REQUEST["message"] != "" )
	{
$handle = fopen("help/".$_REQUEST["id"].".help", "w");
			fwrite($handle, '<?xml version="1.0" encoding="UTF-8"?>
<help>
	<titre>'.utf8_encode(htmlspecialchars ($_REQUEST["titre"])).'</titre>
    <message>'.utf8_encode(htmlspecialchars ($_REQUEST["message"])).'</message>
</help>');
		fclose($handle);
		echo "Message sauvegardé.<br>";
	}
	else
	{
		$edit = true;
		if ( file_exists("help/".$_REQUEST["id"].".help") )
		{
			$xml = simplexml_load_file("help/".$_REQUEST["id"].".help");
			$_REQUEST["message"] = utf8_decode($xml[0]->message);
			$_REQUEST["titre"] = utf8_decode($xml[0]->titre);
		}
		else
		{
			$_REQUEST["message"] = "";
			$_REQUEST["titre"] = "";
		}
		?>
		<form method="post">
		<table>
		<tr>
		<td>
		Id
		</td>
		<td>
		<input type=text name=id value=<?php echo $_REQUEST["id"]; ?> readonly>
		</td>
		</tr>
		<tr>
		<td>
		Titre
		</td>
		<td>
		<input type=text name=titre value="<?php echo $_REQUEST["titre"]; ?>"><br>
		</td>
		</tr>
		<tr>
		<td>
		Message
		</td>
		<td>
		<textarea name="message" rows="5" cols="20"><?php echo $_REQUEST["message"]; ?></textarea><br>
		</td>
		</tr>
		<tr>
		<td colspan=2><center>
		<input type=submit value=ajouter>
		</center>
		</td>
		</tr>
		</table>
		</form>
		<?php
	}
}
if ( ! $edit )
{
	$sommaire = simplexml_load_file("help/sommaire.help");
	$helps = array();
	function scanhelpdir($helps, $dir = ".")
	{
		if ( $dh = opendir($dir) )
		{
			while (($file = readdir($dh)) !== false)
			{
				if ( is_file($dir."/".$file) )
				{
					$content = implode("\n", file($dir."/".$file));
					
					if ( preg_match_all("/help\([\"'](.*)['\"]\)/", $content, $matches, PREG_SET_ORDER) )
					{
						foreach ($matches as $val)
						{
							if ( ! file_exists("help/".$val[1].".help") )
								echo "Manque aide ".$val[1]." du fichier ".$dir."/".$file." <a href=?id=".$val[1].">Go</a><br>";
							else
								array_push($helps, $val[1]);
						}
					}
				}
				elseif ( $file != "." && $file != ".." && $file != ".svn" && is_dir($dir."/".$file) )
				{
					$helps = scanhelpdir($helps, $dir."/".$file);
				}
			}
			closedir($dh);
		}
		return $helps;
	}
	$helps = scanhelpdir($helps);
	sort($helps);
	require("fctphp/function.php");
	echo "<ul class='help'>";
	foreach($helps as $help)
	{
		$findsommaire = $sommaire->xpath("//*[text()='".$help."']");
		echo "<li><form method='post'>Aide ".$help." ".help($help)."
			<input type=hidden name=id value='".$help."'>
			<input type=image src='images/skins/".$GLOBALS["config"]->general->skin."/modifier.png' type=image Value=Modifier>";
		if ( count($findsommaire) == 0 )
			echo " Introuvable dans le sommaire";
		echo "</form></li>";
	}
	echo "<ul>";
}
?>
</body>
</html>
Return current item: Serveur Multicartes IPX800