Barre des quotas toute neuve, merci Manu !
This commit is contained in:
		
							parent
							
								
									50c8877498
								
							
						
					
					
						commit
						48f77aeed6
					
				|  | @ -77,11 +77,10 @@ foreach ($obj_menu as $k => $m ) { | |||
|     foreach( $m['links'] as $l ) { | ||||
|       if ( $l['txt'] == 'progressbar' ) { | ||||
|         $usage_percent = (int) ($l['used'] / $l['total'] * 100); | ||||
|         $usage_color = ( $l['used'] > $l['total'] ? '#800' : '#080'); | ||||
|         $usage_color = ((85 < $usage_percent && $usage_percent <= 100) ? '#ff8800' : $usage_color); // yellow
 | ||||
|         echo "<li>"; | ||||
|         echo '<div class="progress-bar">'; | ||||
|         echo '<div style="width: ' . ($usage_percent > 100 ? 100 : $usage_percent) . '%; background: ' . $usage_color . ';"> </div>'; | ||||
|         echo '<div class="barre" style="width:'.$usage_percent.'%; background-color:'.PercentToColor($usage_percent).'" ></div>'; | ||||
|         //echo '<div class="txt">'.$usage.' %</div>';
 | ||||
|         echo '</div>'; | ||||
|         echo "</li>"; | ||||
|         continue; | ||||
|  |  | |||
|  | @ -7,12 +7,13 @@ if (!defined("QUOTASONE")) return; | |||
| if (!isset($mode)) { # when included from adm_login, mode is not set
 | ||||
|   $mode = 0; | ||||
| } | ||||
| // $mode = 4; // Pour Debuguer le mode "graphique" des quotas
 | ||||
| ?>
 | ||||
| <center> | ||||
| 
 | ||||
| <h3 style="text-align:center;"><?php printf(_("<b>%s</b> account"),$mem->user["login"]); ?></h3>
 | ||||
| 
 | ||||
| <div style="width: 550px"> | ||||
| <div style="width: 600px"> | ||||
| 
 | ||||
| <!-- Webspaces --> | ||||
| 
 | ||||
|  | @ -29,7 +30,7 @@ if (!isset($mode)) { # when included from adm_login, mode is not set | |||
| 
 | ||||
| <!-- Mails --> | ||||
| 
 | ||||
| <table class="tedit" width="90%"> | ||||
| <table class="tedit" width="100%"> | ||||
| <thead> | ||||
| <tr> | ||||
|    <th><?php __("Domains"); ?></th>
 | ||||
|  | @ -101,6 +102,7 @@ if (!isset($mode)) { # when included from adm_login, mode is not set | |||
| </tbody> | ||||
| </table> | ||||
| 
 | ||||
| <p> </p> | ||||
| <!-- Databases --> | ||||
| 
 | ||||
| <?php | ||||
|  | @ -112,7 +114,7 @@ if (!isset($mode)) { # when included from adm_login, mode is not set | |||
|   echo "</p>"; | ||||
| ?>
 | ||||
| 
 | ||||
| <table class="tedit" width="50%"> | ||||
| <table class="tedit" width="100%"> | ||||
| <thead> | ||||
| <tr> | ||||
|   <th width='50%'><?php __("DB"); ?></th>
 | ||||
|  | @ -138,7 +140,7 @@ if (!isset($mode)) { # when included from adm_login, mode is not set | |||
|     } elseif (isset($mode) &&$mode==1) { | ||||
|       echo sprintf("%.1f", $pc)." %"; | ||||
|     } else { | ||||
|       $quota->quota_displaybar(2*$pc); | ||||
|       $quota->quota_displaybar(2*$pc, 0); | ||||
|     } | ||||
|     echo "</td></tr>"; | ||||
|   } | ||||
|  |  | |||
|  | @ -122,8 +122,8 @@ echo "<br /><br />"; printf(_("If you want to manage them, go to")." <a hre | |||
| 
 | ||||
| ?>
 | ||||
| <center> | ||||
| <div style="width: 650px"> | ||||
| <table class="tedit"> | ||||
| <div> | ||||
| <table class="tedit" width="100%"> | ||||
| <thead> | ||||
|    <tr><th> </th><th><?php __("Count"); ?></th><th><?php __("Space"); ?></th></tr>
 | ||||
| </thead> | ||||
|  | @ -163,8 +163,8 @@ echo "<br /><br />"; printf(_("If you want to manage them, go to")." <a hre | |||
| ?>
 | ||||
| <center> | ||||
| 
 | ||||
| <div style="width: 650px"> | ||||
| <table  class="tedit"> | ||||
| <div> | ||||
| <table  class="tedit" width="100%"> | ||||
| <thead> | ||||
| 	    <tr><th rowspan="2"><?php __("Account"); ?></th><th colspan="3"><?php __("Count"); ?></th><th colspan="5"><?php __("Space"); ?></th></tr>
 | ||||
| <tr> | ||||
|  |  | |||
|  | @ -609,6 +609,35 @@ input#dir, input#sub_local { | |||
|   margin-left: 10px; | ||||
| } | ||||
| 
 | ||||
| div.progress-bar { | ||||
|   position: relative; | ||||
|   width: 100%; | ||||
|   height: 20px; | ||||
|   background-color: #fff; | ||||
|   border: solid 1px #aaa; | ||||
|   overflow: hidden; | ||||
|   -webkit-border-radius: 4px; | ||||
|   -moz-border-radius: 4px; | ||||
|   border-radius: 4px;   | ||||
| } | ||||
| 
 | ||||
| div.progress-bar div.barre { | ||||
|   position: absolute; | ||||
|   top: 0; | ||||
|   left: 0; | ||||
|   height: 20px; | ||||
|   background-color: #CCC; | ||||
|   border: none; | ||||
| } | ||||
| 
 | ||||
| div.progress-bar div.txt { | ||||
|   position: absolute; | ||||
|   top: 3px; | ||||
|   left: 0; | ||||
|   width: 100%; | ||||
|   text-align:center;  | ||||
| } | ||||
| 
 | ||||
| .ombrage { | ||||
|   border: 1px solid #888; | ||||
|   box-shadow: 1px 1px 15px #555; | ||||
|  |  | |||
|  | @ -678,4 +678,76 @@ function auto_wrap($message="",$max=10,$wrap_string="<wbr/>") { | |||
|   return $message; | ||||
| } | ||||
| 
 | ||||
| /* | ||||
| **  Converts HSV to RGB values | ||||
| ** ----------------------------------------------------- | ||||
| **  Reference: http://en.wikipedia.org/wiki/HSL_and_HSV | ||||
| **  Purpose:   Useful for generating colours with | ||||
| **             same hue-value for web designs. | ||||
| **  Input:     Hue        (H) Integer 0-360 | ||||
| **             Saturation (S) Integer 0-100 | ||||
| **             Lightness  (V) Integer 0-100 | ||||
| **  Output:    String "R,G,B" | ||||
| **             Suitable for CSS function RGB(). | ||||
| */ | ||||
| 
 | ||||
| function fHSVtoRGB($iH, $iS, $iV) { | ||||
| 
 | ||||
|   if($iH < 0)   $iH = 0;   // Hue:
 | ||||
|   if($iH > 360) $iH = 360; //   0-360
 | ||||
|   if($iS < 0)   $iS = 0;   // Saturation:
 | ||||
|   if($iS > 100) $iS = 100; //   0-100
 | ||||
|   if($iV < 0)   $iV = 0;   // Lightness:
 | ||||
|   if($iV > 100) $iV = 100; //   0-100
 | ||||
| 
 | ||||
|   $dS = $iS/100.0; // Saturation: 0.0-1.0
 | ||||
|   $dV = $iV/100.0; // Lightness:  0.0-1.0
 | ||||
|   $dC = $dV*$dS;   // Chroma:     0.0-1.0
 | ||||
|   $dH = $iH/60.0;  // H-Prime:    0.0-6.0
 | ||||
|   $dT = $dH;       // Temp variable
 | ||||
| 
 | ||||
|   while($dT >= 2.0) $dT -= 2.0; // php modulus does not work with float
 | ||||
|   $dX = $dC*(1-abs($dT-1));     // as used in the Wikipedia link
 | ||||
| 
 | ||||
|   switch($dH) { | ||||
|       case($dH >= 0.0 && $dH < 1.0): | ||||
|           $dR = $dC; $dG = $dX; $dB = 0.0; break; | ||||
|       case($dH >= 1.0 && $dH < 2.0): | ||||
|           $dR = $dX; $dG = $dC; $dB = 0.0; break; | ||||
|       case($dH >= 2.0 && $dH < 3.0): | ||||
|           $dR = 0.0; $dG = $dC; $dB = $dX; break; | ||||
|       case($dH >= 3.0 && $dH < 4.0): | ||||
|           $dR = 0.0; $dG = $dX; $dB = $dC; break; | ||||
|       case($dH >= 4.0 && $dH < 5.0): | ||||
|           $dR = $dX; $dG = 0.0; $dB = $dC; break; | ||||
|       case($dH >= 5.0 && $dH < 6.0): | ||||
|           $dR = $dC; $dG = 0.0; $dB = $dX; break; | ||||
|       default: | ||||
|           $dR = 0.0; $dG = 0.0; $dB = 0.0; break; | ||||
|   } | ||||
| 
 | ||||
|   $dM  = $dV - $dC; | ||||
|   $dR += $dM; $dG += $dM; $dB += $dM; | ||||
|   $dR *= 255; $dG *= 255; $dB *= 255; | ||||
| 
 | ||||
|   return array('r'=>round($dR), 'g'=>round($dG), 'b'=>round($dB) ); | ||||
| } | ||||
| 
 | ||||
| function hexa($hex) | ||||
| { | ||||
|   $num = dechex($hex); | ||||
|   return (strlen("$num") >= 2) ? "$num" : "0$num"; | ||||
| } | ||||
| 
 | ||||
| function PercentToColor($p=0) { | ||||
|   if ($p>100) $p=100; | ||||
|   if ($p<0) $p=0; | ||||
|   // Pour aller de vert a rouge en passant par jaune et orange
 | ||||
|   $h = 1+((100-$p)*130/100); | ||||
|    | ||||
|   $rvb = fHSVtoRGB( (int)$h, 96, 93); | ||||
|   $color = "#".hexa($rvb['r']).hexa($rvb['g']).hexa($rvb['b']); | ||||
|    | ||||
|   return $color; | ||||
| } | ||||
| ?>
 | ||||
|  |  | |||
|  | @ -520,13 +520,24 @@ class m_quota { | |||
|     } | ||||
|   } | ||||
| 
 | ||||
|   // Cette fonction doit disparaitre quand on refera les pages d'affichage du quota
 | ||||
|   // trop sale
 | ||||
|   function quota_displaybar($usage) { | ||||
|     $usage_color = '#A0CFEC'; | ||||
|     $usage_color = ((85 < $usage && $usage <= 100) ? '#82CAFF' : $usage_color); // yellow
 | ||||
|   // Affiche des barres de progression
 | ||||
|   // color_type :
 | ||||
|   //   0 = Pas de changement de couleur
 | ||||
|   //   1 = Progression du vert vers le rouge en fonction du porcentage
 | ||||
|   //   2 = Progression du rouge vers le vert en fonction du porcentage
 | ||||
|   function quota_displaybar($usage, $color_type=1) { | ||||
|     if ($color_type == 1) { | ||||
|       $csscolor = " background-color:".PercentToColor($usage); | ||||
|     } elseif ($color_type == 2) { | ||||
|       $csscolor = " background-color:".PercentToColor(100-$usage); | ||||
|     } else { | ||||
|       $csscolor = ""; | ||||
|     } | ||||
| 
 | ||||
|      | ||||
|     echo '<div class="progress-bar">'; | ||||
|     echo '<div style="width:'.$usage.'%; background: ' . $usage_color . '; text-align:center; font-weight: bold;" >'.$usage.'%</div>'; | ||||
|     echo '<div class="barre" style="width:'.$usage.'%;'.$csscolor.'" ></div>'; | ||||
|     echo '<div class="txt">'.$usage.'%</div>'; | ||||
|     echo '</div>'; | ||||
|   } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue