<html>
<body bgcolor="white">
<?PHP
//////////////////////////////////////////////////////////
        include("config/includes/linkleiste");
        echo "<link rel=stylesheet type=\"text/css\" href=\"config/includes/style.css\">\n";
//////////////////////////////////////////////////////////

	/////////////////////////////////////////////////////////////
echo "<br><div align=center><font class=h1><a class=anker name=anker>Dia Show</a></font></div>";
	///	Section Diashow
	
	if(file_exists(dia_show))
		{
		$array = file("dia_show/names");
		usort($array,"strnatcasecmp");
		$y=0;
                $anzahl = count($array);
                echo "<center><font class=titel>($anzahl Dia Shows sind angelegt)</font></center>\n";
		for($x=0; $x<count($array); $x++)
			{
			$akt_file = ereg_replace("\n","",$array[$x]);
			$z = filesize ("dia_show/shows/$akt_file");
			$y=$y+$z;
			}
		if($y>0)
			{
                        echo "<br><form action=dia_show.php method=get>\n";
			echo "<div align=center><table class=rahmendia width=80% height=15%  cellspacing=5 cellpadding=4 bgcolor=white>\n";
                        echo "<tr valign=middle><td class=dia width=100% valign=middle>\n";
                        echo "<div align=center><font class=anweis>Dia Show starten:</font>&nbsp;&nbsp;\n";
			echo "<select name=dia_bereich>";
                        echo "<option selected value=\"stop\">Auswählen und ...</option>\n";
			for($x=0;$x<count($array);$x++)
			{
			$akt_file = ereg_replace("\n","",$array[$x]);
			$y = filesize("dia_show/shows/$akt_file");
			if($y>0)
				{
				echo "<option>$akt_file</option>";
				}
			}
		echo "</select>&nbsp&nbsp&nbsp&nbsp<input type=submit value=\"... Los !\"></form></nobr></div></td></tr></table></div>";
			}
		}

	echo "<br><div align=center><table class=rahmendia width=80% heigth=15%  cellspacing=5 cellpadding=4 bgcolor=white><tr>";
	echo "<td class=dia width=100% valign=top>\n";
        #echo "<div align=center><font size=4 color=#008080><u><strong>Dia Show erstellen</strong></u></font></div><br>";
	if (isset($new_dia_show))
		{
		if(empty($new_dia_show) || file_exists("dia_show/shows/$new_dia_show"))
			{
			if(empty($new_dia_show))
				{
				echo "<center><font class=error>Sie müssen einen Namen für die Dia Show angeben!</font></center><br>";
				}
			else
				{
				if(file_exists("dia_show/shows/$new_dia_show"))
					{
					echo "<center><font class=\"error\">Die Dia Show \"$new_dia_show\" gibt es schon!</font></center><br>\n";
					}
				}
			}
		else
			{
			if(ereg("(^[0-9A-Za-z\_\-]+$)", $new_dia_show, $regs))
				{
				if(file_exists(dia_show)){}
				else
					{
					mkdir("dia_show",0777);
					chmod("dia_show",0777);
					}
				if(file_exists("dia_show/shows")){}
				else
					{
					mkdir("dia_show/shows",0777);
					chmod("dia_show/shows",0777);
					}
				$file = "dia_show/shows/$new_dia_show";
				$fp = fopen("$file","w-");
				fclose($fp);
				
				$new_config = "<?PHP\n\$art = \"time\";\n\$time = \"20\";\n?>";
				$file = "dia_show/shows/$new_dia_show.conf";
				$fp = fopen("$file","w-");
				fwrite($fp,$new_config);
				fclose($fp);

				$file = "dia_show/names";
				$new_dia_show = "$new_dia_show\n";
				$fp = fopen("$file","a+");
				fwrite ($fp,$new_dia_show);
				fclose ($fp);
				echo "<center><font class=titel>Dia Show \"$new_dia_show\" wurde erstellt</font></center>";
				}
			else
				{
				echo "<center><font class=\"error\">Der Bereichsname darf nicht aus \"ä, ö, ü, ß,\" oder Sonderzei        chen bestehen! Erlaubte Sonderzeichen sind: \"- _\"</font></center><br>\n";
				}
			}
		}

	echo "<br><div align=center><nobr><form action=dia.php method=post class=action><font class=anweis>Den Namen einer neuen Dia Show eingeben:&nbsp;&nbsp;</font> \n";
        echo "<nobr><input type=text name=new_dia_show>&nbsp;&nbsp;&nbsp;<input type=submit value=\"Dia Show erstellen\"></form></nobr>";
	echo "</div><br></td></tr></table></div>";
	
	if(file_exists(dia_show))
		{
		if(isset($dia_bereich) && ($action == "löschen?") && ($delete_dia == true))
			{
			unlink("dia_show/shows/$dia_bereich");
			unlink("dia_show/shows/$dia_bereich.conf");
			$delete_bereich = file("dia_show/names");
			$file = "dia_show/names";
			$fp = fopen("$file","w-");
			for($x=0; $x<count($delete_bereich); $x++)
				{
				$delete_pur = ereg_replace("\n","",$delete_bereich[$x]);
				if($delete_pur != $dia_bereich)
					{
					$new_line = "$delete_pur\n";
					fwrite($fp,$new_line);
					}
				}
			fclose ($fp);
			}
		if(file_exists("dia_show/names"))
			{
			if(filesize("dia_show/names")>0)
				{
				echo "<br><div align=center><table class=rahmendia width=80% border=1 cellspacing=5 cellpadding=4><tr>";
				echo "<td class=dia width=100% valign=top>\n";
                                #echo "<div align=center><font size=4 color=#008080><u><strong>Dia Show bearbeiten oder löschen</strong></u></font></div>";
				if(isset($dia_bereich) && ($action == "löschen?") && ($delete_dia == true))
					{
					echo "<br><div align=center><font class=titel>Dia Show \"$dia_bereich\" wurde gelöscht...</font></div>";
					}
                                echo "<center><table width=60%><tr>\n";
                                echo "<td width=30% ><form action=dia_work.php method=get><div align=center><font class=anweis>Dia Show</font></td>";
				echo "<td width=30%><select name=dia_bereich size=1>";
				$file = file("dia_show/names");
				usort($file,"strnatcasecmp");
				for($y=0;$y<count($file);$y++)
					{
					echo "<option>$file[$y]</option>";
					next($file);
					}
				echo "</select></td><td width=30%><font class=anweis>bearbeiten</font></td><td width=10%>\n";
				echo "<input type=hidden name=action value=bearbeiten>";
				echo "<input type=submit value=Los!></form></td></tr>";
				echo "<tr><td><form action=dia_work.php method=get><div align=center><font class=anweis>Dia Show</font></td>";
				echo "<td><select name=dia_bereich size=1>";
				$file = file("dia_show/names");
				usort($file,"strnatcasecmp");
				for($y=0;$y<count($file);$y++)
					{
					echo "<option>$file[$y]</option>";
					next($file);
					}
				echo "</select></td><td><font class=anweis>löschen</font></td><td>";
				echo "<input type=hidden name=action value=löschen?>";
				echo "<input type=submit value=Los!></form></td></tr></table></td></tr></table>";
				}
			}
		}

	////////////////////////////////////////////////////////////////
	///	Ende Section Dia Schow



?>
</body>
</html>
