Changeset 223

Show
Ignore:
Timestamp:
06/30/06 15:49:50 (2 years ago)
Author:
hans
Message:

* Added ability to sort table columns by clicking on the table headings in the control panel
* Quick & dirty fix for eaccelerator_clear to work with the new cache dir hashing. This still needs to be done for win32.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • eaccelerator/trunk/ChangeLog

    r222 r223  
     12006-06-30  Hans Rakers <hans at parse dot nl> 
     2 
     3        * Added ability to sort table columns by clicking on the table 
     4          headings in the control panel 
     5        * Quick & dirty fix for eaccelerator_clear to work with the new 
     6          cache dir hashing. This still needs to be done for win32. 
     7 
     8          eaccelerator_clean still needs some fixing to work with the 
     9          dir hashing. 
     10 
    1112006-06-27  Bart Vanbrabant <bart.vanbrabant at zoeloelip.be> 
    212 
  • eaccelerator/trunk/control.php

    r181 r223  
    6161/* }}} */ 
    6262 
     63function compare($x, $y) 
     64{ 
     65  global $sortby; 
     66 
     67  if ( $x[$sortby] == $y[$sortby] ) 
     68    return 0; 
     69  else if ( $x[$sortby] < $y[$sortby] ) 
     70    return -1; 
     71  else 
     72    return 1; 
     73} 
     74 
     75function revcompare($x, $y) 
     76{ 
     77  global $sortby; 
     78 
     79  if ( $x[$sortby] == $y[$sortby] ) 
     80    return 0; 
     81  else if ( $x[$sortby] < $y[$sortby] ) 
     82    return 1; 
     83  else 
     84    return -1; 
     85} 
     86    
    6387/* {{{ create_script_table */ 
    64 function create_script_table($list) { ?> 
    65     <table class="scripts"> 
    66         <tr> 
    67             <th>Filename</th> 
    68             <th>MTime</th> 
    69             <th>Size</th> 
    70             <th>Reloads</th> 
    71             <th>Hits</th> 
    72         </tr> 
    73     <?php foreach($list as $script) { ?> 
     88function create_script_table($list) { 
     89  global $sortby; 
     90?> 
     91    <table> 
     92        <tr> 
     93            <th><a href="<?=$_SERVER['PHP_SELF']?>?sort=file&order=<?=($_GET['order'] == "asc" ? "desc" : "asc")?>">Filename</a>&nbsp;<? if($_GET['sort'] == "file") echo ($_GET['order'] == "asc" ? "&darr;" : "&uarr;")?></th> 
     94            <th><a href="<?=$_SERVER['PHP_SELF']?>?sort=mtime&order=<?=($_GET['order'] == "asc" ? "desc" : "asc")?>">MTime</a>&nbsp;<? if($_GET['sort'] == "mtime") echo ($_GET['order'] == "asc" ? "&darr;" : "&uarr;")?></th> 
     95            <th><a href="<?=$_SERVER['PHP_SELF']?>?sort=size&order=<?=($_GET['order'] == "asc" ? "desc" : "asc")?>">Size</a>&nbsp;<? if($_GET['sort'] == "size") echo ($_GET['order'] == "asc" ? "&darr;" : "&uarr;")?></th> 
     96            <th><a href="<?=$_SERVER['PHP_SELF']?>?sort=reloads&order=<?=($_GET['order'] == "asc" ? "desc" : "asc")?>">Reloads</a>&nbsp;<? if($_GET['sort'] == "reloads") echo ($_GET['order'] == "asc" ? "&darr;" : "&uarr;")?></th> 
     97            <th><a href="<?=$_SERVER['PHP_SELF']?>?sort=hits&order=<?=($_GET['order'] == "asc" ? "desc" : "asc")?>">Hits</a>&nbsp;<? if($_GET['sort'] == "hits") echo ($_GET['order'] == "asc" ? "&darr;" : "&uarr;")?></th> 
     98        </tr> 
     99    <?php 
     100          switch ($_GET['sort']) { 
     101            case "mtime": 
     102            case "size": 
     103            case "reloads": 
     104            case "hits": 
     105              $sortby = $_GET['sort']; 
     106              ($_GET['order'] == "asc" ? uasort($list, compare) : uasort($list, revcompare)); 
     107              break; 
     108            case "file": 
     109            default: 
     110              $sortby = "file"; 
     111              ($_GET['order'] == "asc" ? uasort($list, compare) : uasort($list, revcompare)); 
     112               
     113          } 
     114 
     115          foreach($list as $script) { ?> 
    74116        <tr> 
    75117    <?php   if (function_exists('eaccelerator_dasm_file')) { ?> 
     
    79121    <?php   } ?> 
    80122            <td class="vr"><?php echo date('Y-m-d H:i', $script['mtime']); ?></td> 
    81             <td class="vr"><?php echo number_format($script['size'] / 1024, 2); ?>KB</td> 
     123            <td class="vr"><?php echo number_format($script['size'] / 1024, 2); ?> KB</td> 
    82124            <td class="vr"><?php echo $script['reloads']; ?> (<?php echo $script['usecount']; ?>)</td> 
    83125            <td class="vr"><?php echo $script['hits']; ?></td> 
     
    151193        .h,th {background-color: #9999cc; font-weight: bold; color: #000000;} 
    152194        .v,td {background-color: #cccccc; color: #000000;} 
    153         .vr{background-color: #cccccc; text-align: right; color: #000000;
     195        .vr{background-color: #cccccc; text-align: right; color: #000000; white-space: nowrap;
    154196        img {float: right; border: 0px;} 
    155197        hr {width: 600px; background-color: #cccccc; border: 0px; height: 1px; color: #000000;} 
  • eaccelerator/trunk/ea_info.c

    r207 r223  
    7777/* }}} */ 
    7878 
     79/* {{{ clear_filecache(): Helper function to eaccelerator_clear which finds diskcache entries in the hashed dirs and removes them */ 
     80static int clear_filecache() { 
     81#ifndef ZEND_WIN32 
     82        DIR *dp; 
     83        struct dirent *entry; 
     84        char s[MAXPATHLEN]; 
     85        char cwd[MAXPATHLEN]; 
     86        struct stat dirstat; 
     87 
     88        if (getcwd(cwd, MAXPATHLEN)) { 
     89                if ((dp = opendir (".")) != NULL) { 
     90                        while ((entry = readdir (dp)) != NULL) { 
     91                                if (strstr (entry->d_name, "eaccelerator") == entry->d_name) { 
     92                                        strncpy (s, cwd, MAXPATHLEN - 1); 
     93                                        strlcat (s, "/", MAXPATHLEN); 
     94                                        strlcat (s, entry->d_name, MAXPATHLEN); 
     95                                        unlink(s); 
     96                                } 
     97                                if (stat(entry->d_name, &dirstat) != -1) { 
     98                                        if (strcmp(entry->d_name, ".") ==0) 
     99                                                continue; 
     100                                        if (strcmp(entry->d_name, "..") ==0) 
     101                                                continue; 
     102 
     103                                        if (S_ISDIR(dirstat.st_mode)) { 
     104                                                chdir(entry->d_name); 
     105                                                clear_filecache(); 
     106                                                chdir(".."); 
     107                                        } 
     108                                } 
     109                        } 
     110                        closedir (dp); 
     111                } 
     112        } 
     113} 
     114#else 
     115/* WIN32 TODO: rewrite this for hashed cache dirs */ 
     116{ 
     117        HANDLE hList; 
     118        TCHAR szDir[MAXPATHLEN]; 
     119        WIN32_FIND_DATA FileData; 
     120        char s[MAXPATHLEN]; 
     121 
     122        snprintf (szDir, MAXPATHLEN, "%s\\eaccelerator*", EAG (cache_dir)); 
     123 
     124        if ((hList = FindFirstFile (szDir, &FileData)) != INVALID_HANDLE_VALUE) { 
     125                do { 
     126                        strncpy (s, EAG (cache_dir), MAXPATHLEN - 1); 
     127                        strlcat (s, "\\", MAXPATHLEN); 
     128                        strlcat (s, FileData.cFileName, MAXPATHLEN); 
     129                        unlink (s); 
     130                } 
     131                while (FindNextFile (hList, &FileData)); 
     132        } 
     133 
     134                FindClose (hList); 
     135} 
     136#endif 
     137/* }}} */ 
     138 
    79139/* {{{ PHP_FUNCTION(eaccelerator_caching): enable or disable caching */ 
    80140PHP_FUNCTION(eaccelerator_caching)  
     
    256316        EACCELERATOR_UNLOCK_RW (); 
    257317        EACCELERATOR_PROTECT (); 
    258 #ifndef ZEND_WIN32 
    259         /* clear file cache */ 
    260         { 
    261                 DIR *dp; 
    262                 struct dirent *entry; 
    263                 char s[MAXPATHLEN]; 
    264  
    265                 if ((dp = opendir (EAG (cache_dir))) != NULL) { 
    266                         while ((entry = readdir (dp)) != NULL) { 
    267                                 if (strstr (entry->d_name, "eaccelerator") == entry->d_name) { 
    268                                         strncpy (s, EAG (cache_dir), MAXPATHLEN - 1); 
    269                                         strlcat (s, "/", MAXPATHLEN); 
    270                                         strlcat (s, entry->d_name, MAXPATHLEN); 
    271                                         unlink (s); 
    272                                 } 
    273                         } 
    274                         closedir (dp); 
    275                 } 
    276         } 
    277 #else 
    278         { 
    279                 HANDLE hList; 
    280                 TCHAR szDir[MAXPATHLEN]; 
    281                 WIN32_FIND_DATA FileData; 
    282                 char s[MAXPATHLEN]; 
    283  
    284                 snprintf (szDir, MAXPATHLEN, "%s\\eaccelerator*", EAG (cache_dir)); 
    285  
    286                 if ((hList = FindFirstFile (szDir, &FileData)) != INVALID_HANDLE_VALUE) { 
    287                         do { 
    288                                 strncpy (s, EAG (cache_dir), MAXPATHLEN - 1); 
    289                                 strlcat (s, "\\", MAXPATHLEN); 
    290                                 strlcat (s, FileData.cFileName, MAXPATHLEN); 
    291                                 unlink (s); 
    292                         } 
    293                         while (FindNextFile (hList, &FileData)); 
    294                 } 
    295  
    296                 FindClose (hList); 
    297         } 
    298 #endif 
     318         
     319        chdir(EAG (cache_dir)); 
     320        clear_filecache(); 
     321         
    299322    RETURN_NULL(); 
    300323}