directory listing

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • directory listing

    folgendes prob

    http://www.dein-kiel.de/content/galerie/list.php

    Die ersten zwei Zeilen müssen weg, nur wie? häng da jetzt schon Stunden vor und hab einfach kein Plan...


    Der Code dazu:

    PHP Code:
    <?
    $extension = "";
    $i=0;
    $handle=opendir ('.'); 
    while (false !== ($file = readdir ($handle))) {
        $expl = explode(".",$file);
        if ($expl[1] == $extension) {
            $i++; 
            $array[$i] = $file;
        }
    }
    closedir($handle); 
    if ($i > 0) {
        sort($array);
        while (list ($key, $val) = each ($array)) {
            $expl = explode(".",$val);
            $link = "$expl[0]";
            $year = substr("$expl[0]",0,4);
            $month = substr("$expl[0]",5,2);
            $day = substr("$expl[0]",8,2);
            $loc = substr("$expl[0]",11);
                $ausgabe = "Datum: $day.$month.$year        Ort: $loc";
            print "<a href=\"thumb.php?date=$link\">$ausgabe</a><br>\n";    }
    } else {
        print "Sorry, die Datenbank ist leer.";
    }

    ?>
    Kurze Erklärung:

    Ich will ohne viel Aufwand eine kleine Gallerie erstellen.
    Script sucht sich alle Ordner im Verzeichniss wo das Script liegt, sortiert die Ordner nach Datum, verlinkt den Ordner zu einer php die thumbnails aus dem ordnerinhalt erstellt..

    Wie auch immer, die ersten zwei Zeilen müssen weg, nur wie?

    jemand ne idee?

  • #2
    vor dieser zeile ....
    PHP Code:
    $expl explode(".",$file); 
    muss du prüfen, ob $file . oder .. ist. ist das der fall, dann ignorieren.
    INFO: Erst suchen, dann posten![color=red] | [/color]MANUAL(s): PHP | MySQL | HTML/JS/CSS[color=red] | [/color]NICE: GNOME Do | TESTS: Gästebuch[color=red] | [/color]IM: Jabber.org |


    Comment


    • #3
      haste auch zufällig den code dazu?

      Comment


      • #4
        so'n kleines if() wirst du wohl noch selber schaffen. oder?

        wenn nicht, bringt es auch nichts, wenn ich es poste. weil das verstehst du dann sowieso nicht.
        INFO: Erst suchen, dann posten![color=red] | [/color]MANUAL(s): PHP | MySQL | HTML/JS/CSS[color=red] | [/color]NICE: GNOME Do | TESTS: Gästebuch[color=red] | [/color]IM: Jabber.org |


        Comment


        • #5
          ich steh grad nur aufn schlauch wie ich sachen ignoriere

          Comment


          • #6
            schlaf mal drüber

            Rocco

            Comment


            • #7
              hmm hier gabs auch schonmal bessere und vor allem nettere hilfestellungen :/

              naja however

              Comment


              • #8
                heute jemand da der mir helfen kann? =(

                Comment


                • #9
                  Mhn,

                  Prüfen ob die Datei . oder .. ist?

                  Also wenn (if) die Datei ($file) nicht gleich . (==".") oder (||) die Datei ($file) .. ist (=="..") dann zerschneide sie in 2 teile(explode(...)).


                  Floriam
                  PHP Handbuch - MySQL Handbuch - PHP Einsteiger Tutorial - CSS Referenz - Browserunterstützung von CSS

                  Comment


                  • #10
                    habs hinbekommen.

                    hier nochmal die komplett lösung für alle suchenden...

                    PHP Code:
                    <?
                    $extension = "";
                    $i=0;
                    $handle=opendir ("."); 

                    while (false !== ($file = readdir ($handle))) {
                        if ($file == "." || $file == ".."){}
                        else {
                        $expl = explode(".",$file);
                        if ($expl[1] == $extension) {
                            $i++; 
                            $array[$i] = $file;
                        }
                    }}
                    closedir($handle); 
                    if ($i > 0) 
                    {
                            sort($array);
                            while (list ($key, $val) = each ($array)) 
                                    {
                                                     
                                                       $expl = explode(".",$val);
                                                    $link = "$expl[0]";
                                                    $year = substr("$link",0,4);
                                                    $month = substr("$link",5,2);
                                                    $day = substr("$link",8,2);
                                                    $loc = substr("$link",11);
                                                    $ausgabe = "Datum: $day.$month.$year        Ort: $loc";
                                                    echo "<tr><td><a href=\"thumb.php?date=$link\"><b><font face=verdana size=2 color=6699CC>$ausgabe</font></a></b></td></tr>";
                                                    
                                    
                    }} else {
                        print "Sorry, die Datenbank ist leer.";
                    }
                    echo "</table>";
                    include("../includes/bottom.inc");
                    ?>

                    Comment


                    • #11
                      @Floriam
                      nicht gleich . (==".")
                      -> !=

                      noch besser wäre das hier...

                      PHP Code:
                      if ($file != '.' && $file != '..')
                      {
                          
                      $expl explode(".",$file);
                          if (
                      $expl[1] == $extension)
                          {
                              
                      $i++; 
                              
                      $array[$i] = $file;
                          }

                      INFO: Erst suchen, dann posten![color=red] | [/color]MANUAL(s): PHP | MySQL | HTML/JS/CSS[color=red] | [/color]NICE: GNOME Do | TESTS: Gästebuch[color=red] | [/color]IM: Jabber.org |


                      Comment


                      • #12
                        danke für die info, aber das script läuft nun wie ich will und daran wird nich mehr gebastelt ;P

                        Comment

                        Working...
                        X