Changeset 1352
- Timestamp:
- 06/12/08 09:56:08 (2 months ago)
- Files:
-
- trunk/wifidog-auth/CHANGELOG (modified) (1 diff)
- trunk/wifidog-auth/wifidog/classes/AbstractDb.php (modified) (1 diff)
- trunk/wifidog-auth/wifidog/classes/Content/UIAllowedBandwidth/UIAllowedBandwidth.php (modified) (3 diffs)
- trunk/wifidog-auth/wifidog/include/schema_validate.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/wifidog-auth/CHANGELOG
r1351 r1352 1 1 # $Id$ 2 2008-06-12 Benoit Grégoire <bock@step.polymtl.ca> 3 * Use bigint for dynamic abuse control byte values 4 * UIAllowedBandwidth: Format values in a human-readable way 5 2 6 2008-06-10 Benoit Grégoire <bock@step.polymtl.ca> 3 7 * Authenticator.php: Fix SQL error closing connections. trunk/wifidog-auth/wifidog/classes/AbstractDb.php
r1287 r1352 545 545 * @return a string suitable for storage in the database's interval datatype 546 546 */ 547 function GetIntervalStrFromDuration ($duration)547 function GetIntervalStrFromDurationArray($duration) 548 548 { 549 549 $str = ''; 550 if ($duration ->GetYears()!= 0)551 $str .= $duration ->GetYears().' years ';552 if ($duration ->GetMonths()!= 0)553 $str .= $duration ->GetMonths().' months ';554 if ($duration ->GetDays()!= 0)555 $str .= $duration ->GetDays().' days ';556 557 if ($duration ->GetHours() != 0 || $duration->GetMinutes() != 0 || $duration->GetSeconds()!= 0)558 { 559 $str .= $duration ->GetHours().':'.$duration->GetMinutes().':'.$duration->GetSeconds();550 if ($duration['years'] != 0) 551 $str .= $duration['years'].' years '; 552 if ($duration['months'] != 0) 553 $str .= $duration['months'].' months '; 554 if ($duration['days'] != 0) 555 $str .= $duration['days'].' days '; 556 557 if ($duration['hours'] != 0 || $duration['minutes'] != 0 || $duration['seconds'] != 0) 558 { 559 $str .= $duration['hours'].':'.$duration['minutes'].':'.$duration['seconds']; 560 560 } 561 561 return $str; trunk/wifidog-auth/wifidog/classes/Content/UIAllowedBandwidth/UIAllowedBandwidth.php
r1351 r1352 57 57 class UIAllowedBandwidth extends Content 58 58 { 59 59 60 /** 60 61 * Constructor … … 88 89 return Content :: getAdminUI($html, $title); 89 90 } 90 91 /* Format human readable filesize */ 92 static function formatSize($size, $round = 0) { 93 //Size must be bytes! 94 $sizes = array(_('B'), _('kB'), _('MB'), _('GB'), _('TB'), _('PB'), _('EB'), _('ZB'), _('YB')); 95 for ($i=0; $size > 1024 && $i < count($sizes) - 1; $i++) $size /= 1024; 96 return round($size,$round).$sizes[$i]; 97 } 91 98 /** 92 99 * Retreives the user interface of this object. … … 103 110 104 111 $user = User::getCurrentUser(); 105 106 if($current_node){ 107 $abuseControlReport = User::getAbuseControlConnectionHistory($user, null, $current_node); 108 if($abuseControlReport) { 109 //pretty_print_r($abuseControlReport); 112 if ($user) { 113 if($current_node){ 114 $abuseControlReport = User::getAbuseControlConnectionHistory($user, null, $current_node); 115 if($abuseControlReport) { 116 //pretty_print_r($abuseControlReport); 117 $db = AbstractDb::getObject(); 118 $html .= sprintf(_("During the last %s period, you transfered %s / %s and were connected %s / %s at this node. Throughout the network, you transfered %s / %s and were connected %s / %s"), 119 $abuseControlReport['connection_limit_window']?$db->GetIntervalStrFromDurationArray($db->GetDurationArrayFromIntervalStr($abuseControlReport['connection_limit_window'])):_("Unknown"), 120 self::formatSize($abuseControlReport['node_total_bytes']), 121 $abuseControlReport['connection_limit_node_max_total_bytes']?self::formatSize($abuseControlReport['connection_limit_node_max_total_bytes']):_("Unlimited"), 122 $abuseControlReport['node_duration']?$abuseControlReport['node_duration']:_("None"), 123 $abuseControlReport['connection_limit_node_max_usage_duration']?$abuseControlReport['connection_limit_node_max_usage_duration']:_("Unlimited"), 124 self::formatSize($abuseControlReport['network_total_bytes']), 125 $abuseControlReport['connection_limit_network_max_total_bytes']?self::formatSize($abuseControlReport['connection_limit_network_max_total_bytes']):_("Unlimited"), 126 $abuseControlReport['network_duration']?$abuseControlReport['network_duration']:_("None"), 127 $abuseControlReport['connection_limit_network_max_usage_duration']?$abuseControlReport['connection_limit_network_max_usage_duration']:_("Unlimited") 128 ); 110 129 111 $html .= sprintf(_("During the last %s period, you transfered %s / %s bytes and were connected %s / %s at this node. Throughout the network, you transfered %s / %s bytes and were connected %s / %s"), 112 $abuseControlReport['connection_limit_window']?$abuseControlReport['connection_limit_window']:_("Unknown"), 113 $abuseControlReport['node_total_bytes']?$abuseControlReport['node_total_bytes']:_("Unknown"), 114 $abuseControlReport['connection_limit_node_max_total_bytes']?$abuseControlReport['connection_limit_node_max_total_bytes']:_("Unlimited"), 115 $abuseControlReport['node_duration']?$abuseControlReport['node_duration']:_("Unknown"), 116 $abuseControlReport['connection_limit_node_max_usage_duration']?$abuseControlReport['connection_limit_node_max_usage_duration']:_("Unlimited"), 117 $abuseControlReport['network_total_bytes']?$abuseControlReport['network_total_bytes']:_("Unknown"), 118 $abuseControlReport['connection_limit_network_max_total_bytes']?$abuseControlReport['connection_limit_network_max_total_bytes']:_("Unlimited"), 119 $abuseControlReport['network_duration']?$abuseControlReport['network_duration']:_("Unknown"), 120 $abuseControlReport['connection_limit_network_max_usage_duration']?$abuseControlReport['connection_limit_network_max_usage_duration']:_("Unlimited") 121 ); 122 130 } 131 else { 132 $html .= _("Abuse control is currently disabled"); 133 } 123 134 } 124 135 else { 125 $html .= _(" Abuse control is currently disabled");136 $html .= _("Unable to retrieve node specific restrictions (you are not at a node)"); 126 137 } 138 $this->setUserUIMainDisplayContent($html); 139 140 return Content :: getUserUI(); 127 141 } 128 else {129 $html .= _("Unable to retrieve node specific restrictions (you are not at a node)");130 }131 $this->setUserUIMainDisplayContent($html);132 return Content :: getUserUI();133 142 } 134 143 trunk/wifidog-auth/wifidog/include/schema_validate.php
r1351 r1352 48 48 * Define current database schema version 49 49 */ 50 define('REQUIRED_SCHEMA_VERSION', 6 1);50 define('REQUIRED_SCHEMA_VERSION', 62); 51 51 /** Used to test a new shecma version before modyfying the database */ 52 52 define('SCHEMA_UPDATE_TEST_MODE', false); … … 1405 1405 1406 1406 } 1407 1407 $new_schema_version = 62; 1408 if ($schema_version < $new_schema_version && $new_schema_version <= $targetSchema) { 1409 printUpdateVersion($new_schema_version); 1410 $sql .= "\n\nUPDATE schema_info SET value='$new_schema_version' WHERE tag='schema_version';\n"; 1411 1412 $sql .= "ALTER TABLE networks ALTER COLUMN connection_limit_network_max_total_bytes TYPE bigint;\n"; 1413 $sql .= "ALTER TABLE networks ALTER COLUMN connection_limit_node_max_total_bytes TYPE bigint;\n"; 1414 1415 $sql .= "ALTER TABLE nodes ALTER COLUMN connection_limit_node_max_total_bytes_override TYPE bigint;\n"; 1416 1417 } 1408 1418 /* 1409 1419 $new_schema_version = ;
