PHP file management, can be clicked by time, size, name sort _php Tutorial

Source: Internet
Author: User

PHP file management, can be clicked by time, size, name sort

This example does not use jquery

Demonstrate

PHP Code
  1. $rootdir = "./";
  2. $spacenum = 0;
  3. $filenum = 0;
  4. $allfilesize = 0;
  5. echo "

    File Management Freejs.net Testing

    ";
  6. echo "Reset";
  7. Readlogdir ($rootdir);
  8. echo "";
  9. echo "Total Files Count: $filenum.
    ";
  10. echo "Total disk space used: $allfilesize
    ";
  11. $freespace =diskfreespace ("/");
  12. echo "Residue disk space: $freespace
    ";
  13. function Readlogdir ($subdir) {
  14. Global $rootdir, $spacenum, $filenum, $allfilesize;
  15. @chdir ($subdir) or Die ("Error:could not directory!");
  16. $dirobject =dir ($subdir);
  17. echo "
  18. $i = 0;
  19. $allfilesize +=filesize ($file);
  20. while ($file = $dirobject->read ()) {
  21. if ($file = = "." | | $file = = "..") {
  22. Continue
  23. }
  24. $i = $i +1;
  25. echo "
  26. $filenum + +;
  27. }
  28. echo "
  29. "; ";
    Filename File size Creation time
    ". $i.";
  30. echo $file. "
  31. ". Number_format ((filesize ($file)/1024), 2, '. ', '). " Kb ". Date ("Y-m-d h:i:s", Filemtime ($file)). "
    ";
  32. Return
  33. }
  34. ?>
  35. JavaScript Code
    1. /**
    2. * Table Sort
    3. * Anthor Liueh
    4. */
    5. function Jm_powerlist (colnum)
    6. {
    7. headeventobject=event.srcelement;//gets the object that raised the event
    8. while (headeventobject.tagname!= "tr")//Not TR line, the TD bubbles up from the bottom to find the corresponding line
    9. {
    10. Headeventobject=headeventobject.parentelement;
    11. }
    12. for (i=0;i
    13. {
    14. if (headeventobject.children[i]!=event.srcelement)//Find the TD cell where the event occurred
    15. {
    16. Headeventobject.children[i].classname= ' listtablehead ';//Set the ClassName property of the clicked column to Listtablehead
    17. }
    18. }
    19. var tablerows=0;
    20. Trobject=clearstart.children[0].children; Get the object in the table, the original is called a DataTable, maybe you wrote wrong??
    21. for (i=0;i
    22. {
    23. object=clearstart.children[0].children[i];//gets the object for each row
    24. tablerows= (trobject[i].id== ' Ignore ')? tablerows:tablerows+1;//if the row is not ignored, the number of rows plus one
    25. }
    26. var trinnerhtml=new Array (tablerows);
    27. var tdinnerhtml=new Array (tablerows);
    28. var tdnumber=new Array (tablerows)
    29. var i0=0
    30. var i1=0
    31. for (i=0;i
    32. {
    33. if (trobject[i].id!= ' ignore ')
    34. {
    35. trinnerhtml[i0]=trobject[i].innerhtml;//put the line in the array.
    36. tdinnerhtml[i0]=trobject[i].children[colnum].innerhtml;//put the contents of the TD in the row to be sorted into an array
    37. tdnumber[i0]=i;//line number
    38. i0++;//plus one, next cycle with
    39. }
    40. }
    41. sourcehtml=clearstart.children[0].outerhtml;//get the HTML code for all TR in the table
    42. Sorting the strings in all TD is not a bubble sort???
    43. for (Bi=0;bi
    44. {
    45. for (i=0;i
    46. {
    47. if (tdinnerhtml[i]>tdinnerhtml[i+1])
    48. {
    49. T_S=TDNUMBER[I+1];
    50. T_b=tdnumber[i];
    51. Tdnumber[i+1]=t_b;
    52. tdnumber[i]=t_s;
    53. TEMP_SMALL=TDINNERHTML[I+1];
    54. Temp_big=tdinnerhtml[i];
    55. Tdinnerhtml[i+1]=temp_big;
    56. Tdinnerhtml[i]=temp_small;
    57. }
    58. }
    59. }
    60. var showshow= ';
    61. var numshow= ';
    62. for (i=0;i
    63. {
    64. showshow=showshow+tdinnerhtml[i]+ ' \ n ';//the contents of the sorted TD are in the Showshow string
    65. numshow=numshow+tdnumber[i]+ ' | '; The corresponding line number of the sort is also present in Numshow
    66. }
    67. Sourcehtml_head=sourcehtml.split ("");//from truncation, I tried, the string ahead is empty
    68. Numshow=numshow.split ("|");
    69. var trrebuildhtml= ';
    70. if (event.srcelement.classname== ' listheadclicked ')
    71. {//clicked column, reverse row
    72. for (i=0;i
    73. {
    74. trrebuildhtml=trrebuildhtml+trobject[numshow[tablerows-1-i]].outerhtml;//take out the contents of the ordered TR to link up
    75. }
    76. Event.srcelement.classname= ' listHeadClicked0 ';
    77. }
    78. Else
    79. {//default straight, new click to row
    80. for (i=0;i
    81. {
    82. trrebuildhtml=trrebuildhtml+trobject[numshow[i]].outerhtml;
    83. }
    84. Event.srcelement.classname= ' listheadclicked ';
    85. }
    86. Gets the ordered TR collection result string
    87. var datarebuildtable= ';
    88. Connect the old table header with the new TR sorted elements (modified)
    89. Datarebuildtable = "
    90. "
    91. "+ trobject[0].outerhtml + trrebuildhtml +" "+
      ";
    92. clearstart.outerhtml=datarebuildtable;//table to be re-written with a new string
    93. }


      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 ...

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.