Advertisement
Guest User

Untitled

a guest
Jul 30th, 2017
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.54 KB | None | 0 0
  1. <?php
  2. echo "Navigation: <a href='index.php'>Start</a> - <a href='?navi=bilder'>Alle Bilder anzeigen</a> - <a href='?navi=fehlt'>Fehlt noch</a>";
  3. echo "<hr>";
  4. if (!isset($_GET[id])) {
  5.     echo "Klicke auf den Namen, um den Steckbrief zu bearbeiten!<br><br>";
  6. }
  7. $dir = dir(".");
  8. $id = 1;
  9. $zahl = 0;
  10. while (false !== ($folder = $dir->read())) {
  11.     if ($folder !== "." && $folder !== ".." && $folder !== "index.php" && $folder !== "error.jpg"){
  12.         if ($_GET[navi] != "fehlt" && !isset($_GET[id])) {
  13.             echo $id." - <a href='?id=".$id."'><b>".$folder."\n"."</b></a><br>";
  14.         }
  15.         $subdir = dir("./".$folder);
  16.        
  17.         //Pseudo-Datenbank
  18.         $name[$id] = $folder;
  19.         $aktuell[$id] = "<font color='red'>nein</font>";
  20.         $alt[$id] = "<font color='red'>nein</font>";
  21.         $aktuellpath[$id] = "error.jpg";
  22.         $altpath[$id] = "error.jpg";
  23.        
  24.         //Bilder anzeigen
  25.         while (false !== ($file = $subdir->read())) {
  26.             if ($file !== "." && $file !== ".." && $file !== "..."){
  27.                 if ($_GET[navi] == "bilder") {
  28.                     if(strpos($file,".txt")==false){
  29.                         echo "<img src='".$folder."/".$file."' height='400px'>";
  30.                     }
  31.                 }
  32.             }
  33.             if(strpos($file,"aktuell")!==false){
  34.                 $aktuell[$id] = "<font color='green'>ja</font>";
  35.                 $aktuellpath[$id] = $folder."/".$file;
  36.             }
  37.             if(strpos($file,"alt")!==false){
  38.                 $alt[$id] = "<font color='green'>ja</font>";
  39.                 $altpath[$id] = $folder."/".$file;
  40.             }
  41.         }
  42.                 if ($_GET[navi] == "bilder") {
  43.             echo "<br>";
  44.         }
  45.         if ($_GET[navi] == "fehlt") {
  46.             if($aktuell[$id] == "<font color='red'>nein</font>" || $alt[$id] == "<font color='red'>nein</font>"){
  47.                 echo $id." - <a href='?id=".$id."'><b>".$folder."\n"."</b></a><br>";   
  48.                 $zahl++;
  49.             }
  50.         }
  51.         $subdir->close();
  52.         if ($_GET[navi] == "fehlt") {
  53.             if($aktuell[$id] == "<font color='red'>nein</font>" || $alt[$id] == "<font color='red'>nein</font>"){
  54.                 echo "Aktuelles Bild? ".$aktuell[$id]."<br>";
  55.                 echo "Altes Bild? ".$alt[$id]."<br><br>";
  56.             }          
  57.         }
  58.         if ($_GET[navi] != "fehlt" && !isset($_GET[id])){
  59.             echo "Aktuelles Bild? ".$aktuell[$id]."<br>";
  60.             echo "Altes Bild? ".$alt[$id]."<br><br>";
  61.         }
  62.     $id++; 
  63.     }
  64. }
  65. if (isset($_GET[id])) {
  66.     echo $name[$_GET[id]]."<br>";
  67.     echo "<img src='".$aktuellpath[$_GET[id]]."' height='400px'>";
  68.     echo "<img src='".$altpath[$_GET[id]]."' height='400px'><br>";
  69.     echo "Aktuelles Bild? ".$aktuell[$_GET[id]]."<br>";
  70.     echo "Altes Bild? ".$alt[$_GET[id]]."<br><br>";
  71.    
  72.     //Steckbrief anlegen
  73.     $datei = $name[$_GET[id]]."/".$name[$_GET[id]]." Steckbrief.txt";
  74.     if(!file_exists($filename)) {
  75.     $fp = fopen($datei, "a");
  76.     fclose($fp);
  77.     }
  78.    
  79.     if (!isset($_POST["steckbrief"])) {
  80.         $fp = fopen($datei, "rb");
  81.         if(filesize($datei) == 0){
  82.             $inhalt = fgets($fp);
  83.         }else{
  84.             $inhalt = fread($fp, filesize($datei));
  85.         }
  86.         echo "Steckbrief:<br><form method='post'><textarea cols='80' rows='10' name='steckbrief'>".$inhalt."</textarea><br><input type=\"submit\" value=\"Daten senden\"></form>";
  87.         fclose($fp);
  88.     }
  89.     if (isset($_POST["steckbrief"])) {
  90.         $fp = fopen($datei, "w+");
  91.         rewind($fp);
  92.         $steckbrief = $_POST["steckbrief"];
  93.         fputs($fp,$steckbrief);
  94.         fclose($fp);
  95.         //Auslesen
  96.         $fp = fopen($datei, "rb");
  97.         $inhalt = fread($fp, filesize($datei));
  98.         echo "Steckbrief:<br><form method='post'><textarea cols='80' rows='10' name='steckbrief'>".$inhalt."</textarea><br><input type=\"submit\" value=\"Daten senden\"></form>";
  99.         fclose($fp);
  100.         echo "<br>Fertig!";
  101.     }
  102. }
  103. $dir->close();
  104. if ($_GET[navi] == "fehlt") {
  105. echo "So viele Schüler haben ihre Bilder für die Abi-Zeitung noch nicht vollständig abgeliefert: ".$zahl;
  106. }
  107. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement