Hi Leute,
erstmal hallo, bin neu hier. Ich schlage mich jetzt schon seit Wochen mit einem Problem herum und komme nicht wirklich weiter. Ich will eine Blätterfunktion in ein Script einbauen, bekomme das aber nicht so ganz hin. In dem Verzeichnis werden einzelne Textfiles abgelegt, also keine MySQL-Datenbank, denn da wäre es einfach anhand der Tutorials die ich durchgelesen habe. Ich würde gerne 25 Treffer aus dem Verzeichnis pro Seite ausgeben wollen. Aber ich bin Neueinsteiger in PHP und was Flatfiles etc. angeht, gibt es nicht so viele Tutorials. Das Script sieht wie folgt aus:
Alles anzeigen
Hat jemand einen Tipp für mich, wie ich das realisieren kann mit der Blätterfunktion?
Gruß inekai
erstmal hallo, bin neu hier. Ich schlage mich jetzt schon seit Wochen mit einem Problem herum und komme nicht wirklich weiter. Ich will eine Blätterfunktion in ein Script einbauen, bekomme das aber nicht so ganz hin. In dem Verzeichnis werden einzelne Textfiles abgelegt, also keine MySQL-Datenbank, denn da wäre es einfach anhand der Tutorials die ich durchgelesen habe. Ich würde gerne 25 Treffer aus dem Verzeichnis pro Seite ausgeben wollen. Aber ich bin Neueinsteiger in PHP und was Flatfiles etc. angeht, gibt es nicht so viele Tutorials. Das Script sieht wie folgt aus:
Quellcode
- <?php
- include("./config.php");
- if(isset($_GET['act'])){$act = $_GET['act'];}else{$act = "null";}
- session_start();
- include("./header.php");
- if($enable_filelist==false){
- echo "This page is disabled.";
- include("./footer.php");
- die();
- }
- ?>
- <center><table style='margin-top:0px;width:100%;height:400px;'><tr><td style='border:0px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:0px;text-align:left;' valign=top>
- <h1><center>File List</h1>
- <p><table width="100%" cellpadding="2" cellspacing="2" border="0">
- <tr><td bgcolor=#C0C0C0>No</td><td width="50%" bgcolor=#C0C0C0><a href=files.php?sortby=filename style=color:black><b>Filename</b></a></td><td bgcolor=#C0C0C0><a href=files.php?sortby=cat style=color:black><b>Catagory</b></td><td bgcolor=#C0C0C0><a href=files.php style=color:black><b>Downloads</b></a></td><td bgcolor=#C0C0C0><b>Size</b></td><td bgcolor=#C0C0C0><b>Last Download</b></td></tr>
- <tr><td colspan=6 height=1 bgcolor=#969696></td></tr>
- <?php
- if(isset($_GET['act'])){$act = $_GET['act'];}else{$act = "null";}
- // Rename PATHTO with the mapname where you keep the config.php
- include("./config.php");
- if($enable_filelist == false){
- echo "File List Is Disabled.";
- die();
- }
- $order = array();
- $dirname = "./files";
- $dh = opendir( $dirname ) or die("couldn't open directory");
- while ( $file = readdir( $dh ) ) {
- if ($file != '.' && $file != '..' && $file != '.htaccess') {
- $fh = fopen ("./files/".$file, r);
- $list= explode('|', fgets($fh));
- $filecrc = str_replace(".txt","",$file);
- if ($_GET['sortby'] == "filename") {
- $order[] = $list[1].','.$filecrc.','.$list[5].",".$list[4].",".$list[8];
- } elseif($_GET['sortby'] == "cat"){
- $order[] = $list[8].','.$filecrc.','.$list[5].",".$list[4].",".$list[1];
- } else {
- $order[] = $list[5].','.$filecrc.','.$list[1].",".$list[4].",".$list[8];
- }
- fclose ($fh);
- }
- }
- if (isset($_GET['sortby'])) {
- sort($order, SORT_STRING);
- } else {
- sort($order, SORT_NUMERIC);
- $order = array_reverse($order);
- }
- $i = 1;
- foreach($order as $line)
- {
- $line = explode(',', $line);
- $shourturl==$me;
- if ($me=="true")
- $short= "";
- else
- $short= "download.php?file=";
- if ($_GET['sortby'] == "filename") {
- echo "<tr><td bgcolor=#E8E8E8>".$i."</td><td bgcolor=#E8E8E8><a href=\"" . $scripturl . "$me$short" . $line[1] . "\">".$line[0]."</a></td><td bgcolor=#E8E8E8>".$line[4]."</td><td bgcolor=#E8E8E8>".$line[2]."</td>";
- } elseif($_GET['sortby'] == "cat"){
- echo "<tr><td bgcolor=#E8E8E8>".$i."</td><td bgcolor=#E8E8E8><a href=\"" . $scripturl . "$me$short" . $line[1] . "\">".$line[4]."</a></td><td bgcolor=#E8E8E8>".$line[0]."</td><td bgcolor=#E8E8E8>".$line[2]."</td>";
- } else {
- echo "<tr><td bgcolor=#E8E8E8>".$i."</td><td bgcolor=#E8E8E8><a href=\"" . $scripturl . "$me$short" . $line[1] . "\">".$line[2]."</a></td><td bgcolor=#E8E8E8>".$line[4]."</td><td bgcolor=#E8E8E8>".$line[0]."</td>";
- }
- // Rename PATHTO with the mapname where you keep the "storage" map
- $filesize = filesize("./storage/".$line[1]);
- $filesize = ($filesize / 1048576);
- if ($filesize < 1)
- {
- $filesize = round($filesize*1024,0);
- echo "<td bgcolor=#E8E8E8>" . $filesize . " KB</td>";
- }
- else
- {
- $filesize = round($filesize,0);
- echo "<td bgcolor=#E8E8E8>" . $filesize . " MB</td>";
- }
- echo "<td bgcolor=#E8E8E8>".date('Y-m-d G:i', $line[3])."</td></tr>";
- $i++;
- }
- ?>
- <tr><td colspan=6 height=1 bgcolor=#969696></td></tr>
- <tr><td colspan=6>
- <?
- function total_size($dir) {
- $handle = opendir($dir);
- while($file = readdir($handle)) {
- $total = $total + filesize ($dir.$file);
- if((is_dir($dir.$file.'/')) &&($file != '..')&&($file != '.'))
- {
- $total = $total + total_size($dir.$file.'/');
- }
- }
- return $total;
- }
- $total = total_size('storage/');
- $total = $total / 1048576;
- $total = round($total,0);
- echo "<span style=color:gray>Total Size: " . $total." MB</span>";
- ?>
- </td></tr>
- </table>
- <br>
- <br>
- <? include("./bottomads.php"); ?>
- </center></td></tr></table><p style="margin:3px;text-align:center"><?
- include("./footer.php");
- ?>
Hat jemand einen Tipp für mich, wie ich das realisieren kann mit der Blätterfunktion?
Gruß inekai