PHP file management, can be clicked by time, size, name sort
This example does not use jquery
Demonstrate
PHP Code
- $rootdir = "./";
- $spacenum = 0;
- $filenum = 0;
- $allfilesize = 0;
- echo "
File Management Freejs.net Testing
";
- echo "Reset";
- Readlogdir ($rootdir);
- echo "";
- echo "Total Files Count: $filenum.
";
- echo "Total disk space used: $allfilesize
";
- $freespace =diskfreespace ("/");
- echo "Residue disk space: $freespace
";
- function Readlogdir ($subdir) {
- Global $rootdir, $spacenum, $filenum, $allfilesize;
- @chdir ($subdir) or Die ("Error:could not directory!");
- $dirobject =dir ($subdir);
- echo "
- $i = 0;
- $allfilesize +=filesize ($file);
- while ($file = $dirobject->read ()) {
- if ($file = = "." | | $file = = "..") {
- Continue
- }
- $i = $i +1;
- echo "
- $filenum + +;
- }
- echo "
Filename |
File size |
Creation time |
";
". $i.";- echo $file. "
|
". Number_format ((filesize ($file)/1024), 2, '. ', '). " Kb |
". Date ("Y-m-d h:i:s", Filemtime ($file)). " |
";
";
- Return
- }
- ?>
- JavaScript Code
- /**
- * Table Sort
- * Anthor Liueh
- */
- function Jm_powerlist (colnum)
- {
- headeventobject=event.srcelement;//gets the object that raised the event
- while (headeventobject.tagname!= "tr")//Not TR line, the TD bubbles up from the bottom to find the corresponding line
- {
- Headeventobject=headeventobject.parentelement;
- }
- for (i=0;i
- {
- if (headeventobject.children[i]!=event.srcelement)//Find the TD cell where the event occurred
- {
- Headeventobject.children[i].classname= ' listtablehead ';//Set the ClassName property of the clicked column to Listtablehead
- }
- }
- var tablerows=0;
- Trobject=clearstart.children[0].children; Get the object in the table, the original is called a DataTable, maybe you wrote wrong??
- for (i=0;i
- {
- object=clearstart.children[0].children[i];//gets the object for each row
- tablerows= (trobject[i].id== ' Ignore ')? tablerows:tablerows+1;//if the row is not ignored, the number of rows plus one
- }
- var trinnerhtml=new Array (tablerows);
- var tdinnerhtml=new Array (tablerows);
- var tdnumber=new Array (tablerows)
- var i0=0
- var i1=0
- for (i=0;i
- {
- if (trobject[i].id!= ' ignore ')
- {
- trinnerhtml[i0]=trobject[i].innerhtml;//put the line in the array.
- tdinnerhtml[i0]=trobject[i].children[colnum].innerhtml;//put the contents of the TD in the row to be sorted into an array
- tdnumber[i0]=i;//line number
- i0++;//plus one, next cycle with
- }
- }
- sourcehtml=clearstart.children[0].outerhtml;//get the HTML code for all TR in the table
- Sorting the strings in all TD is not a bubble sort???
- for (Bi=0;bi
- {
- for (i=0;i
- {
- if (tdinnerhtml[i]>tdinnerhtml[i+1])
- {
- T_S=TDNUMBER[I+1];
- T_b=tdnumber[i];
- Tdnumber[i+1]=t_b;
- tdnumber[i]=t_s;
- TEMP_SMALL=TDINNERHTML[I+1];
- Temp_big=tdinnerhtml[i];
- Tdinnerhtml[i+1]=temp_big;
- Tdinnerhtml[i]=temp_small;
- }
- }
- }
- var showshow= ';
- var numshow= ';
- for (i=0;i
- {
- showshow=showshow+tdinnerhtml[i]+ ' \ n ';//the contents of the sorted TD are in the Showshow string
- numshow=numshow+tdnumber[i]+ ' | '; The corresponding line number of the sort is also present in Numshow
- }
- Sourcehtml_head=sourcehtml.split ("");//from truncation, I tried, the string ahead is empty
- Numshow=numshow.split ("|");
- var trrebuildhtml= ';
- if (event.srcelement.classname== ' listheadclicked ')
- {//clicked column, reverse row
- for (i=0;i
- {
- trrebuildhtml=trrebuildhtml+trobject[numshow[tablerows-1-i]].outerhtml;//take out the contents of the ordered TR to link up
- }
- Event.srcelement.classname= ' listHeadClicked0 ';
- }
- Else
- {//default straight, new click to row
- for (i=0;i
- {
- trrebuildhtml=trrebuildhtml+trobject[numshow[i]].outerhtml;
- }
- Event.srcelement.classname= ' listheadclicked ';
- }
- Gets the ordered TR collection result string
- var datarebuildtable= ';
- Connect the old table header with the new TR sorted elements (modified)
- Datarebuildtable = "
- "
"+ trobject[0].outerhtml + trrebuildhtml +"
"+
";
- clearstart.outerhtml=datarebuildtable;//table to be re-written with a new string
- }
Original address: http://www.freejs.net/article_jquerywenzi_147.html
http://www.bkjia.com/PHPjc/769113.html www.bkjia.com true http://www.bkjia.com/PHPjc/769113.html techarticle PHP file Management, can click by time, size, name sort This example does not use jquery to demonstrate PHP Code $rootdir = "." $spacenum =0; $filenum =0; $allfilesize =0; echo "File management ...
-