starhunter: Wie ich aus einem anderen forum zitieren darf:
Zitat
Und natürlich darfst du eine der größten Programmiererungenschaften ablehnen/verweigern.
Ich bin der meinung das oop einfach nichts für mich ist ... manchmal weiß man in einem code einfach nicht wo plötzlich welche variable herkommt und welchen inhalt sie hat. Funktionsaufrufe müssen umständlicher gesteuert werden ($new->klasse::funktion()) dieses 3fach aufrufen für eine sache mag ich halt nicht !
Größere projekte können mit einer guten struktur und genügend wissen auch wunderbar prozedual abgearbeitet werden
Funktionale programmierung halt:
ein beispiel von mir:
(Dateien eines verzeichniss auflisten und ausgeben [bilder musik und archive ] )
<span class="syntaxdefault"><br /></span><span class="syntaxcomment">//absoluter pfad zum webserver hauptverzeichnis (bei einem webspace zb. eigenes verzeichnis)<br /></span><span class="syntaxdefault">$docroot </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">getenv</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'DOCUMENT_ROOT'</span><span class="syntaxkeyword">);<br /></span><span class="syntaxcomment">//upload-verzeichnis pfade<br /></span><span class="syntaxdefault">$dirarr </span><span class="syntaxkeyword">= array(</span><span class="syntaxdefault">$docroot</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">$docroot</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">$docroot</span><span class="syntaxkeyword">);<br /><br /></span><span class="syntaxcomment">//Ordner auflisten und inhalt in entsprechungseinheit umgewandelt ('Byte','KB','MB','GB','TB','PB')<br />/**<br />* @ array() $dirarr<br /> * return array( array(inhalt) )<br /> *<br /> * $data = dirOverview($dirarr);<br /> * @ $data = array(3) {<br /> * [0]=>array(1) {[0]=>string(80) "Ordner: docroot/files/uploads/images/ <br> Speicher belegt: 253.81 KB <br>" }<br /> * [1]=>array(1) {[0]=>string(79) "Ordner: docroot/files/uploads/archive/ <br> Speicher belegt: 1.24 KB <br>" }<br /> * [2]=>array(1) {[0]=>string(78) "Ordner: docroot/files/uploads/musik/ <br> Speicher belegt: 17.83 MB <br>"}<br /> * }<br /> */<br /><br /><br /></span><span class="syntaxkeyword">function </span><span class="syntaxdefault">dirOverview</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$dirarr</span><span class="syntaxkeyword">) {<br /></span><span class="syntaxdefault">$datax </span><span class="syntaxkeyword">= array();<br /></span><span class="syntaxdefault">$doc </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">getenv</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'DOCUMENT_ROOT'</span><span class="syntaxkeyword">).</span><span class="syntaxstring">'/'</span><span class="syntaxkeyword">;<br />foreach (</span><span class="syntaxdefault">$dirarr </span><span class="syntaxkeyword">as </span><span class="syntaxdefault">$dirkey </span><span class="syntaxkeyword">=> </span><span class="syntaxdefault">$dirval</span><span class="syntaxkeyword">) {<br /> </span><span class="syntaxdefault">$data </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">benSpeicher</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$dirval</span><span class="syntaxkeyword">);<br /> </span><span class="syntaxdefault">$size </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">calcfilesize</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$data</span><span class="syntaxkeyword">);<br /> </span><span class="syntaxdefault">$dir </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">str_replace</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$doc</span><span class="syntaxkeyword">,</span><span class="syntaxstring">''</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">$dirval</span><span class="syntaxkeyword">);<br /> </span><span class="syntaxdefault">$datax</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">$dirkey</span><span class="syntaxkeyword">]= array(</span><span class="syntaxstring">'Ordner:<br> ::'</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">$dir</span><span class="syntaxkeyword">.</span><span class="syntaxstring">':: <br> Speicher belegt: '</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">$size</span><span class="syntaxkeyword">.</span><span class="syntaxstring">' <br>'</span><span class="syntaxkeyword">);<br /> </span><span class="syntaxdefault">$output </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">$datax</span><span class="syntaxkeyword">;<br />}<br /> return </span><span class="syntaxdefault">$output</span><span class="syntaxkeyword">;<br />}<br /><br /><br />function </span><span class="syntaxdefault">fileList</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$dirarr</span><span class="syntaxkeyword">) {<br /></span><span class="syntaxdefault">$filterName </span><span class="syntaxkeyword">= array(</span><span class="syntaxstring">'listBilder'</span><span class="syntaxkeyword">,</span><span class="syntaxstring">'listArchive'</span><span class="syntaxkeyword">,</span><span class="syntaxstring">'listMusik'</span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">$data </span><span class="syntaxkeyword">= array();<br />foreach (</span><span class="syntaxdefault">$dirarr </span><span class="syntaxkeyword">as </span><span class="syntaxdefault">$dirkey </span><span class="syntaxkeyword">=> </span><span class="syntaxdefault">$dirval</span><span class="syntaxkeyword">) {<br /> </span><span class="syntaxdefault">$data </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">scandir</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$dirval</span><span class="syntaxkeyword">);<br /> </span><span class="syntaxdefault">$data2</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">$dirkey</span><span class="syntaxkeyword">] = </span><span class="syntaxdefault">array_filter</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$data</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">$filterName</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">$dirkey</span><span class="syntaxkeyword">]);<br /> </span><span class="syntaxdefault">$output </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">$data2</span><span class="syntaxkeyword">;<br /><br />}<br />return </span><span class="syntaxdefault">$output</span><span class="syntaxkeyword">;<br />}<br /><br />function </span><span class="syntaxdefault">ulimgcont</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$data</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">$list</span><span class="syntaxkeyword">) {<br /> echo </span><span class="syntaxstring">'<h5>'</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">$data</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">][</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">].</span><span class="syntaxstring">'</h5>'</span><span class="syntaxkeyword">;<br /> echo </span><span class="syntaxstring">'<h5>Dateien:</h5>'</span><span class="syntaxkeyword">;<br /> foreach(</span><span class="syntaxdefault">$list</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">] as </span><span class="syntaxdefault">$file1</span><span class="syntaxkeyword">){<br /> </span><span class="syntaxdefault">$dir </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">$data</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">][</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">];<br /> </span><span class="syntaxdefault">$dir </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">str_replace</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">getenv</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'DOCUMENT_ROOT'</span><span class="syntaxkeyword">).</span><span class="syntaxstring">"/"</span><span class="syntaxkeyword">,</span><span class="syntaxstring">"::"</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">$dir</span><span class="syntaxkeyword">);<br /> </span><span class="syntaxdefault">$dir </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">str_replace</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"/<br/>"</span><span class="syntaxkeyword">,</span><span class="syntaxstring">"::"</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">$dir</span><span class="syntaxkeyword">);<br /> </span><span class="syntaxdefault">$regex </span><span class="syntaxkeyword">= </span><span class="syntaxstring">"/::.*::/"</span><span class="syntaxkeyword">;<br /> </span><span class="syntaxdefault">preg_match</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$regex</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">$dir</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">$match_1</span><span class="syntaxkeyword">);<br /> </span><span class="syntaxdefault">$match_1</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">] = </span><span class="syntaxdefault">str_replace</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"::"</span><span class="syntaxkeyword">, </span><span class="syntaxstring">""</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">$match_1</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">]);<br /> echo </span><span class="syntaxstring">'<p><a class="filelink" href="'</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">$server</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">$match_1</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">].</span><span class="syntaxdefault">$file1</span><span class="syntaxkeyword">.</span><span class="syntaxstring">'">'</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">ucfirst</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$file1</span><span class="syntaxkeyword">).</span><span class="syntaxstring">'</a><br>'</span><span class="syntaxkeyword">;<br /> </span><span class="syntaxdefault">$type </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">substr</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$file1</span><span class="syntaxkeyword">, -</span><span class="syntaxdefault">4</span><span class="syntaxkeyword">);<br /> echo </span><span class="syntaxstring">'Dateigröße: '</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">display_filesize</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$match_1</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">].</span><span class="syntaxdefault">$file1</span><span class="syntaxkeyword">).</span><span class="syntaxstring">'<br> Dateityp:'</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">$type</span><span class="syntaxkeyword">.</span><span class="syntaxstring">'<br></p>'</span><span class="syntaxkeyword">;<br /> }<br />}<br />function </span><span class="syntaxdefault">ularchcont</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$data</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">$list</span><span class="syntaxkeyword">) {<br /> echo </span><span class="syntaxstring">'<h5>'</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">$data</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">][</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">].</span><span class="syntaxstring">'</h5>'</span><span class="syntaxkeyword">;<br /> echo </span><span class="syntaxstring">'<h5>Dateien:</h5>'</span><span class="syntaxkeyword">;<br /> foreach(</span><span class="syntaxdefault">$list</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">] as </span><span class="syntaxdefault">$file2</span><span class="syntaxkeyword">){<br /> </span><span class="syntaxdefault">$dir </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">$data</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">][</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">];<br /> </span><span class="syntaxdefault">$dir </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">str_replace</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">getenv</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'DOCUMENT_ROOT'</span><span class="syntaxkeyword">).</span><span class="syntaxstring">"/"</span><span class="syntaxkeyword">,</span><span class="syntaxstring">"::"</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">$dir</span><span class="syntaxkeyword">);<br /> </span><span class="syntaxdefault">$dir </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">str_replace</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"/<br/>"</span><span class="syntaxkeyword">,</span><span class="syntaxstring">"::"</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">$dir</span><span class="syntaxkeyword">);<br /> </span><span class="syntaxdefault">$regex </span><span class="syntaxkeyword">= </span><span class="syntaxstring">"/::.*::/"</span><span class="syntaxkeyword">;<br /> </span><span class="syntaxdefault">preg_match</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$regex</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">$dir</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">$match_1</span><span class="syntaxkeyword">);<br /> </span><span class="syntaxdefault">$match_1</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">] = </span><span class="syntaxdefault">str_replace</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"::"</span><span class="syntaxkeyword">, </span><span class="syntaxstring">""</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">$match_1</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">]);<br /> echo </span><span class="syntaxstring">'<p><a class="filelink" href="'</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">$server</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">$match_1</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">].</span><span class="syntaxdefault">$file2</span><span class="syntaxkeyword">.</span><span class="syntaxstring">'">'</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">ucfirst</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$file2</span><span class="syntaxkeyword">).</span><span class="syntaxstring">'</a><br>'</span><span class="syntaxkeyword">;<br /> </span><span class="syntaxdefault">$type </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">substr</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$file2</span><span class="syntaxkeyword">, -</span><span class="syntaxdefault">4</span><span class="syntaxkeyword">);<br /> echo </span><span class="syntaxstring">'Dateigröße: '</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">display_filesize</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$match_1</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">].</span><span class="syntaxdefault">$file2</span><span class="syntaxkeyword">).</span><span class="syntaxstring">'<br> Dateityp:'</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">$type</span><span class="syntaxkeyword">.</span><span class="syntaxstring">'<br></p>'</span><span class="syntaxkeyword">;<br /> }<br />}<br /><br />function </span><span class="syntaxdefault">ulmuscont</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$data</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">$list</span><span class="syntaxkeyword">) {<br /> echo </span><span class="syntaxstring">'<h5>'</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">$data</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">2</span><span class="syntaxkeyword">][</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">].</span><span class="syntaxstring">'</h5>'</span><span class="syntaxkeyword">;<br /> echo </span><span class="syntaxstring">'<h5>Dateien:</h5>'</span><span class="syntaxkeyword">;<br /> foreach(</span><span class="syntaxdefault">$list</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">2</span><span class="syntaxkeyword">] as </span><span class="syntaxdefault">$file3</span><span class="syntaxkeyword">){<br /> </span><span class="syntaxdefault">$dir </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">$data</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">2</span><span class="syntaxkeyword">][</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">];<br /> </span><span class="syntaxdefault">$dir </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">str_replace</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">getenv</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'DOCUMENT_ROOT'</span><span class="syntaxkeyword">).</span><span class="syntaxstring">"/"</span><span class="syntaxkeyword">,</span><span class="syntaxstring">"::"</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">$dir</span><span class="syntaxkeyword">);<br /> </span><span class="syntaxdefault">$dir </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">str_replace</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"/<br/>"</span><span class="syntaxkeyword">,</span><span class="syntaxstring">"::"</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">$dir</span><span class="syntaxkeyword">);<br /> </span><span class="syntaxdefault">$regex </span><span class="syntaxkeyword">= </span><span class="syntaxstring">"/::.*::/"</span><span class="syntaxkeyword">;<br /> </span><span class="syntaxdefault">preg_match</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$regex</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">$dir</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">$match_1</span><span class="syntaxkeyword">);<br /> </span><span class="syntaxdefault">$match_1</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">] = </span><span class="syntaxdefault">str_replace</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"::"</span><span class="syntaxkeyword">, </span><span class="syntaxstring">""</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">$match_1</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">]);<br /> echo </span><span class="syntaxstring">'<p><a class="filelink" href="'</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">$server</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">$match_1</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">].</span><span class="syntaxdefault">$file3</span><span class="syntaxkeyword">.</span><span class="syntaxstring">'">'</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">ucfirst</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$file3</span><span class="syntaxkeyword">).</span><span class="syntaxstring">'</a><br>'</span><span class="syntaxkeyword">;<br /> </span><span class="syntaxdefault">$type </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">substr</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$file3</span><span class="syntaxkeyword">, -</span><span class="syntaxdefault">4</span><span class="syntaxkeyword">);<br /> echo </span><span class="syntaxstring">'Dateigröße: '</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">display_filesize</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$match_1</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">].</span><span class="syntaxdefault">$file3</span><span class="syntaxkeyword">).</span><span class="syntaxstring">'<br> Dateityp:'</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">$type</span><span class="syntaxkeyword">.</span><span class="syntaxstring">'<br></p>'</span><span class="syntaxkeyword">;<br /> }<br />}<br /><br />function </span><span class="syntaxdefault">ulusercont</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$data</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">$list</span><span class="syntaxkeyword">) {<br />echo </span><span class="syntaxstring">'<h5>'</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">$data</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">3</span><span class="syntaxkeyword">][</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">].</span><span class="syntaxstring">'</h5>'</span><span class="syntaxkeyword">;<br /> echo </span><span class="syntaxstring">'<h5>Dateien:</h5>'</span><span class="syntaxkeyword">;<br /> foreach(</span><span class="syntaxdefault">$list</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">3</span><span class="syntaxkeyword">] as </span><span class="syntaxdefault">$file4</span><span class="syntaxkeyword">){<br /> </span><span class="syntaxdefault">$dir </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">$data</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">3</span><span class="syntaxkeyword">][</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">];<br /> </span><span class="syntaxdefault">$dir </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">str_replace</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">getenv</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'DOCUMENT_ROOT'</span><span class="syntaxkeyword">).</span><span class="syntaxstring">"/"</span><span class="syntaxkeyword">,</span><span class="syntaxstring">"::"</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">$dir</span><span class="syntaxkeyword">);<br /> </span><span class="syntaxdefault">$dir </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">str_replace</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"/<br/>"</span><span class="syntaxkeyword">,</span><span class="syntaxstring">"::"</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">$dir</span><span class="syntaxkeyword">);<br /> </span><span class="syntaxdefault">$regex </span><span class="syntaxkeyword">= </span><span class="syntaxstring">"/::.*::/"</span><span class="syntaxkeyword">;<br /> </span><span class="syntaxdefault">preg_match</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$regex</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">$dir</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">$match_1</span><span class="syntaxkeyword">);<br /> </span><span class="syntaxdefault">$match_1</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">] = </span><span class="syntaxdefault">str_replace</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"::"</span><span class="syntaxkeyword">, </span><span class="syntaxstring">""</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">$match_1</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">]);<br /> echo </span><span class="syntaxstring">'<p><a class="filelink" href="'</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">$server</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">$match_1</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">].</span><span class="syntaxdefault">$file4</span><span class="syntaxkeyword">.</span><span class="syntaxstring">'">'</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">ucfirst</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$file4</span><span class="syntaxkeyword">).</span><span class="syntaxstring">'</a><br>'</span><span class="syntaxkeyword">;<br /> </span><span class="syntaxdefault">$type </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">substr</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$file3</span><span class="syntaxkeyword">, -</span><span class="syntaxdefault">4</span><span class="syntaxkeyword">);<br /> echo </span><span class="syntaxstring">'Dateigröße: '</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">display_filesize</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$match_1</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">].</span><span class="syntaxdefault">$file4</span><span class="syntaxkeyword">).</span><span class="syntaxstring">'<br> Dateityp:'</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">$type</span><span class="syntaxkeyword">.</span><span class="syntaxstring">'<br></p>'</span><span class="syntaxkeyword">;<br /> }<br />}<br /><br /></span><span class="syntaxcomment">//Speicherbelegung anzeigen<br /></span><span class="syntaxkeyword">function </span><span class="syntaxdefault">benSpeicher</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$dir</span><span class="syntaxkeyword">) {<br /> if ( </span><span class="syntaxdefault">is_file </span><span class="syntaxkeyword">( </span><span class="syntaxdefault">$dir </span><span class="syntaxkeyword">) )<br /> return </span><span class="syntaxdefault">filesize</span><span class="syntaxkeyword">( </span><span class="syntaxdefault">$dir </span><span class="syntaxkeyword">);<br /> if( </span><span class="syntaxdefault">strlen</span><span class="syntaxkeyword">( </span><span class="syntaxdefault">$dir </span><span class="syntaxkeyword">) - </span><span class="syntaxdefault">1 </span><span class="syntaxkeyword">!= </span><span class="syntaxstring">'\\' </span><span class="syntaxkeyword">|| </span><span class="syntaxdefault">strlen</span><span class="syntaxkeyword">( </span><span class="syntaxdefault">$dir </span><span class="syntaxkeyword">) - </span><span class="syntaxdefault">1 </span><span class="syntaxkeyword">!= </span><span class="syntaxstring">'/' </span><span class="syntaxkeyword">)<br /> </span><span class="syntaxdefault">$dir </span><span class="syntaxkeyword">.= </span><span class="syntaxstring">'/'</span><span class="syntaxkeyword">;<br /> </span><span class="syntaxdefault">$handle </span><span class="syntaxkeyword">= @</span><span class="syntaxdefault">opendir</span><span class="syntaxkeyword">( </span><span class="syntaxdefault">$dir </span><span class="syntaxkeyword">);<br /> if( !</span><span class="syntaxdefault">$handle </span><span class="syntaxkeyword">)<br /> return </span><span class="syntaxdefault">false</span><span class="syntaxkeyword">;<br /> while ( ( </span><span class="syntaxdefault">$file </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">readdir</span><span class="syntaxkeyword">( </span><span class="syntaxdefault">$handle </span><span class="syntaxkeyword">) ) !== </span><span class="syntaxdefault">false </span><span class="syntaxkeyword">) {<br /> if( </span><span class="syntaxdefault">$file </span><span class="syntaxkeyword">!= </span><span class="syntaxstring">'.' </span><span class="syntaxkeyword">&& </span><span class="syntaxdefault">$file </span><span class="syntaxkeyword">!= </span><span class="syntaxstring">'..' </span><span class="syntaxkeyword">) {<br /> </span><span class="syntaxdefault">$use </span><span class="syntaxkeyword">+= </span><span class="syntaxdefault">benSpeicher</span><span class="syntaxkeyword">( </span><span class="syntaxdefault">$dir</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">$file </span><span class="syntaxkeyword">);<br /> }<br /> }<br /> </span><span class="syntaxdefault">closedir</span><span class="syntaxkeyword">( </span><span class="syntaxdefault">$handle </span><span class="syntaxkeyword">);<br /> return </span><span class="syntaxdefault">$use</span><span class="syntaxkeyword">;<br />}<br /><br /></span><span class="syntaxcomment">//echo 'Speicherbelegung: ' . benSpeicher("../upload/") . ' Bytes';<br /><br />//datei einlesen<br /></span><span class="syntaxkeyword">function </span><span class="syntaxdefault">dateiLesen</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$datei</span><span class="syntaxkeyword">){<br /></span><span class="syntaxdefault">$file_ok </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">file_exists</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$datei</span><span class="syntaxkeyword">);<br />if (</span><span class="syntaxdefault">$file_ok</span><span class="syntaxkeyword">) {<br /> </span><span class="syntaxdefault">$open </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">fopen</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$datei</span><span class="syntaxkeyword">,</span><span class="syntaxstring">'r'</span><span class="syntaxkeyword">);<br /> </span><span class="syntaxdefault">$dat_gr </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">filesize</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$datei</span><span class="syntaxkeyword">);<br /> </span><span class="syntaxdefault">$dat_les </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">fread</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$open</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">$dat_gr</span><span class="syntaxkeyword">);<br /> return </span><span class="syntaxdefault">$dat_les</span><span class="syntaxkeyword">;<br /><br /> </span><span class="syntaxdefault">fclose</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$open</span><span class="syntaxkeyword">);<br /> } else {<br /> return </span><span class="syntaxdefault">0</span><span class="syntaxkeyword">;<br /> }<br />}<br /><br /></span><span class="syntaxcomment">//datei schreiben<br /></span><span class="syntaxkeyword">function </span><span class="syntaxdefault">dateiSchreiben</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$datei</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">$towrite</span><span class="syntaxkeyword">) {<br /></span><span class="syntaxdefault">$datei </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">fopen</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$datei</span><span class="syntaxkeyword">,</span><span class="syntaxstring">"w+"</span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">fwrite</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$datei</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">$towrite</span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">fclose</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$datei</span><span class="syntaxkeyword">);<br /><br />}<br /><br /></span><span class="syntaxcomment">//dateigröße umgerechnet in entsprechung anzeigen. (datei selbst)<br /></span><span class="syntaxkeyword">function </span><span class="syntaxdefault">display_filesize</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$file</span><span class="syntaxkeyword">){<br /> </span><span class="syntaxdefault">$filesize </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">filesize</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$file</span><span class="syntaxkeyword">);<br /> if(</span><span class="syntaxdefault">is_numeric</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$filesize</span><span class="syntaxkeyword">)){<br /> </span><span class="syntaxdefault">$decr </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">1024</span><span class="syntaxkeyword">; </span><span class="syntaxdefault">$step </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">0</span><span class="syntaxkeyword">;<br /> </span><span class="syntaxdefault">$prefix </span><span class="syntaxkeyword">= array(</span><span class="syntaxstring">'Byte'</span><span class="syntaxkeyword">,</span><span class="syntaxstring">'KB'</span><span class="syntaxkeyword">,</span><span class="syntaxstring">'MB'</span><span class="syntaxkeyword">,</span><span class="syntaxstring">'GB'</span><span class="syntaxkeyword">,</span><span class="syntaxstring">'TB'</span><span class="syntaxkeyword">,</span><span class="syntaxstring">'PB'</span><span class="syntaxkeyword">);<br /><br /> while((</span><span class="syntaxdefault">$filesize </span><span class="syntaxkeyword">/ </span><span class="syntaxdefault">$decr</span><span class="syntaxkeyword">) > </span><span class="syntaxdefault">0.9</span><span class="syntaxkeyword">){<br /> </span><span class="syntaxdefault">$filesize </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">$filesize </span><span class="syntaxkeyword">/ </span><span class="syntaxdefault">$decr</span><span class="syntaxkeyword">;<br /> </span><span class="syntaxdefault">$step</span><span class="syntaxkeyword">++;<br /> }<br /> return </span><span class="syntaxdefault">round</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$filesize</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">2</span><span class="syntaxkeyword">).</span><span class="syntaxstring">' '</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">$prefix</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">$step</span><span class="syntaxkeyword">];<br /> } else {<br /><br /> return </span><span class="syntaxstring">'0 Byte'</span><span class="syntaxkeyword">;<br /> }<br />}<br /><br /></span><span class="syntaxcomment">//dateigröße umrechnen mit übergebenem integer<br /><br /><br />//images auflisten<br /></span><span class="syntaxkeyword">function </span><span class="syntaxdefault">listBilder</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$file</span><span class="syntaxkeyword">) {<br /> if ((</span><span class="syntaxdefault">substr</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$file</span><span class="syntaxkeyword">, -</span><span class="syntaxdefault">4</span><span class="syntaxkeyword">) === </span><span class="syntaxstring">'.gif'</span><span class="syntaxkeyword">) || (</span><span class="syntaxdefault">substr</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$file</span><span class="syntaxkeyword">, -</span><span class="syntaxdefault">4</span><span class="syntaxkeyword">) ===</span><span class="syntaxstring">'.jpg'</span><span class="syntaxkeyword">) || (</span><span class="syntaxdefault">substr</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$file</span><span class="syntaxkeyword">, -</span><span class="syntaxdefault">4</span><span class="syntaxkeyword">) === </span><span class="syntaxstring">'.png'</span><span class="syntaxkeyword">)) {<br /> return </span><span class="syntaxdefault">$file</span><span class="syntaxkeyword">;<br /> }<br />}<br /><br /></span><span class="syntaxcomment">//musik auflisten<br /></span><span class="syntaxkeyword">function </span><span class="syntaxdefault">listMusik</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$file</span><span class="syntaxkeyword">) {<br /> if ((</span><span class="syntaxdefault">substr</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$file</span><span class="syntaxkeyword">, -</span><span class="syntaxdefault">4</span><span class="syntaxkeyword">) === </span><span class="syntaxstring">'.mp3'</span><span class="syntaxkeyword">) || (</span><span class="syntaxdefault">substr</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$file</span><span class="syntaxkeyword">, -</span><span class="syntaxdefault">4</span><span class="syntaxkeyword">) ===</span><span class="syntaxstring">'.mp4'</span><span class="syntaxkeyword">) || (</span><span class="syntaxdefault">substr</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$file</span><span class="syntaxkeyword">, -</span><span class="syntaxdefault">4</span><span class="syntaxkeyword">) === </span><span class="syntaxstring">'.wav'</span><span class="syntaxkeyword">)) {<br /> return </span><span class="syntaxdefault">$file</span><span class="syntaxkeyword">;<br /> }<br />}<br /><br /></span><span class="syntaxcomment">//archive auflisten<br /></span><span class="syntaxkeyword">function </span><span class="syntaxdefault">listArchive</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$file</span><span class="syntaxkeyword">) {<br /> if ((</span><span class="syntaxdefault">substr</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$file</span><span class="syntaxkeyword">, -</span><span class="syntaxdefault">4</span><span class="syntaxkeyword">) === </span><span class="syntaxstring">'.rar'</span><span class="syntaxkeyword">) || (</span><span class="syntaxdefault">substr</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$file</span><span class="syntaxkeyword">, -</span><span class="syntaxdefault">4</span><span class="syntaxkeyword">) ===</span><span class="syntaxstring">'.zip'</span><span class="syntaxkeyword">) || (</span><span class="syntaxdefault">substr</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$file</span><span class="syntaxkeyword">, -</span><span class="syntaxdefault">3</span><span class="syntaxkeyword">) === </span><span class="syntaxstring">'.7z'</span><span class="syntaxkeyword">)) {<br /> return </span><span class="syntaxdefault">$file</span><span class="syntaxkeyword">;<br /> }<br />}<br /> </span><span class="syntaxdefault"></span>
Gut die ausgabe ist etwas umständlich gemacht aber das ist ne sehr sehr frühe version meines codes
wenn ich es nun ausgeben will rufe ich einfach die 2 funktionen auf die mir die daten liefern (auslesen und sortieren) und übergebe diese an die einzelnen ausgabefunktionen XD
LG
R4Zz0R