function rule_panel(){ $sql="SELECT * FROM squid_pools WHERE ID={$_GET["rule-id"]}"; $q=new mysql(); $ligne=@mysql_fetch_array($q->QUERY_SQL($sql,'artica_backup')); $edit=Paragraphe("bandwith-limit-edit-64.png","{edit_the_rule}","{edit_the_rule} {$ligne["rulename"]}","javascript:EditBandRule({$_GET["rule-id"]})"); $delete=Paragraphe("bandwith-limit-del-64.png","{delete_rule}","{delete_rule} {$ligne["rulename"]}", "javascript:DeleteBandRule({$_GET["rule-id"]})"); $time=Paragraphe("64-planning.png","{time_restriction}","{squid_band_time_restriction_text}", "javascript:BandAclTime({$_GET["rule-id"]})"); $net=Paragraphe("bandwith-limit-user-64.png","{networks}","{squid_band_net_restriction_text}", "javascript:BandAclNet({$_GET["rule-id"]})"); $domains=Paragraphe("bandwith-limit-www-64.png","{websites}","{squid_band_www_restriction_text}", "javascript:BandAclWWW({$_GET["rule-id"]})"); $file=Paragraphe("64-filetype.png","{by_file_type}","{squid_band_file_restriction_text}", "javascript:BandAclFILE({$_GET["rule-id"]})"); $tr[]=$edit; $tr[]=$delete; $tr[]=$net; $tr[]=$domains; $tr[]=$file; $tr[]=$time; $tables[]="<table style='width:100%'><tr>"; $t=0; while (list ($key, $line) = each ($tr) ){ $line=trim($line); if($line==null){continue;} $t=$t+1; $tables[]="<td valign='top'>$line</td>"; if($t==2){$t=0;$tables[]="</tr><tr>";} } if($t<2){ for($i=0;$i<=$t;$i++){ $tables[]="<td valign='top'> </td>"; } } $tables[]="</table>"; $maintext=rule_format_text($ligne["total_net"],$ligne["total_users"]); $s=new squid_bandwith_builder(); $s->compile(); $html=implode("\n",$tables)." <hr> <div class=text-info>".@implode("<br>",$s->rules_explain[$_GET["rule-id"]])." {then} $maintext</div> <input type='hidden' id='right-panel-id' value='{$_GET["rule-id"]}'>"; $tpl=new templates(); echo $tpl->_ENGINE_parse_body("$html"); }
function rules_popup() { $html = "<table>\n\t<tr>\n\t\t<td>" . Paragraphe("bandwith-limit-64-add.png", "{add_rule}", "{add_bandwith_rule}", "javascript:AddBandRule()") . "</td>\n\t</tr>\n\t"; $sql = "SELECT * FROM squid_pools ORDER BY ID"; $q = new mysql(); $results = $q->QUERY_SQL($sql, "artica_backup"); while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { $text = rule_format_text($ligne["total_net"], $ligne["total_users"]); $html = $html . "\t<tr>\n\t\t<td>" . Paragraphe("bandwith-limit-64.png", "{$ligne["rulename"]}", "{$text}", "javascript:SquidBandRightPanel('{$ligne["ID"]}')") . "</td>\n\t</tr>"; } $html = $html . "</table>"; $tpl = new templates(); echo $tpl->_ENGINE_parse_body($html); }
function rules_add() { $button_title = "{add}"; $ID = $_GET["ID"]; $t = $_GET["t"]; if (!is_numeric($ID)) { $ID = 0; } $enable = 1; if ($ID > 0) { $sql = "SELECT * FROM squid_pools WHERE ID={$ID}"; $q = new mysql(); $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, 'artica_backup')); $rule_format_text = "<div class=explain style='font-size:18px;margin-bottom:20px'>" . rule_format_text($ID) . "</div>"; $total_net_max = $ligne["total_net_max"]; $total_net_band = $ligne["total_net_band"]; $total_computer_max = $ligne["total_computer_max"]; $total_computer_band = $ligne["total_computer_band"]; $total_user_max = $ligne["total_user_max"]; $total_user_band = $ligne["total_user_band"]; $total_member_max = $ligne["total_member_max"]; $total_member_band = $ligne["total_member_band"]; if ($total_member_max > 0) { $total_member_max = $total_member_max / 1024; $total_member_max = $total_member_max / 1024; } if ($total_member_band > 0) { $total_member_band = $total_member_band * 8; $total_member_band = $total_member_band / 1000; $total_member_band_kbs = " " . $total_member_band / 8 . "Ko/s"; } if ($total_net_max > 0) { $total_net_max = $total_net_max / 1024; $total_net_max = $total_net_max / 1024; } if ($total_computer_max > 0) { $total_computer_max = $total_computer_max / 1024; $total_computer_max = $total_computer_max / 1024; } if ($total_net_band > 0) { $total_net_band = $total_net_band * 8; $total_net_band = $total_net_band / 1000; $total_net_band_kbs = " " . $total_net_band / 8 . "Ko/s"; } if ($total_computer_band > 0) { $total_computer_band = $total_computer_band * 8; $total_computer_band = $total_computer_band / 1000; $total_computer_band_kbs = " " . $total_computer_band / 8 . "Ko/s"; } if ($total_user_max > 0) { $total_user_max = $total_user_max / 1024; $total_user_max = $total_user_max / 1024; } $total_user_band_kbs = null; if ($total_user_band > 0) { $total_user_band = $total_user_band * 8; $total_user_band = $total_user_band / 1000; $total_user_band_kbs = " " . $total_user_band / 8 . "Ko/s"; } $rule_name = $ligne["rulename"]; $t = explode("/", $ligne["total_net"]); $delay_pool_net = $t[0]; $delay_pool_net = $delay_pool_net * 8; $delay_pool_net = $delay_pool_net / 1000; $t = explode("/", $ligne["total_users"]); $delay_pool_limit = $t[0]; $delay_pool_limit = $delay_pool_limit * 8; $delay_pool_limit = $delay_pool_limit / 1000; $delay_pool_max_file = $t[1]; $delay_pool_max_file = $delay_pool_max_file * 8; $delay_pool_max_file = $delay_pool_max_file / 1000; $button_title = "{apply}"; $enable = $ligne["enable"]; $rule_class = $ligne["rule_class"]; } $rules_classes[1] = "{class} 1"; $rules_classes[2] = "{class} 2"; $rules_classes[3] = "{class} 3"; $rules_classes[4] = "{class} 4"; $rules_classes[5] = "{class} 5"; if (!is_numeric($rule_class)) { $rule_class = 2; } $rule_name = utf8_encode($rule_name); $page = CurrentPageName(); $html = "\n\t<div id='DelayPoolDiv' style='width:98%' class=form>\n\t{$rule_format_text}\n\t<input type='hidden' id='ID' value='{$ID}'>\n\t<table style='width:100%'>\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:22px'>{rule_name}:</td>\n\t\t<td style='font-size:14px'>" . Field_text("rule_name", $rule_name, 'width:350px;font-size:22px;padding:3px') . "</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:22px' nowrap>{activate_rule}:</td>\n\t\t<td style='font-size:13px'>" . Field_checkbox_design("enable", 1, $enable, "BadwEnableCheck()") . "</td>\n\t</tr>\n\n\t\t\t\t\n\t\t\t\t\n\t<tr><td colspan=2><hr></td></tr>\t\t\t\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:22px' nowrap>{limit_the_whole_network}:</td>\n\t\t<td style='font-size:13px'>" . Field_checkbox_design("total_net_enabled", 1, $ligne["total_net_enabled"], "total_net_enabled_check()") . "</td>\n\t</tr>\t\n\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:22px'>{delay_pool_max_field}:</td>\t\n\t\t<td style='font-size:22px'>" . Field_text("total_net_max", $total_net_max, 'width:150px;font-size:22px;padding:3px') . " Kb</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:22px'>{delay_pool_param_user_limit}:</td>\t\n\t\t<td style='font-size:22px'>" . Field_text("total_net_band", $total_net_band, 'width:150px;font-size:22px;padding:3px') . " kbps{$total_net_band_kbs}</td>\n\t</tr>\n\t<tr><td colspan=2><hr></td></tr>\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:22px' nowrap>{limit_by_subnet}:</td>\n\t\t<td style='font-size:13px'>" . Field_checkbox_design("total_computer_enabled", 1, $ligne["total_computer_enabled"], "total_computer_enabled_check()") . "</td>\n\t</tr>\t\n\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:22px'>{delay_pool_max_field}:</td>\t\n\t\t<td style='font-size:22px'>" . Field_text("total_computer_max", $total_computer_max, 'width:150px;font-size:22px;padding:3px') . " Kb</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:22px'>{delay_pool_param_user_limit}:</td>\t\n\t\t<td style='font-size:22px'>" . Field_text("total_computer_band", $total_computer_band, 'width:150px;font-size:22px;padding:3px') . " kbps{$total_computer_band_kbs}</td>\n\t</tr>\n\t<tr><td colspan=2><hr></td></tr>\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:22px' nowrap>{limit_by_computer}:</td>\n\t\t<td style='font-size:13px'>" . Field_checkbox_design("total_user_enabled", 1, $ligne["total_user_enabled"], "total_user_enabled_check()") . "</td>\n\t</tr>\t\n\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:22px'>{delay_pool_max_field}:</td>\t\n\t\t<td style='font-size:22px'>" . Field_text("total_user_max", $total_user_max, 'width:150px;font-size:22px;padding:3px') . " Kb</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:22px'>{delay_pool_param_user_limit}:</td>\t\n\t\t<td style='font-size:22px'>" . Field_text("total_user_band", $total_user_band, 'width:150px;font-size:22px;padding:3px') . " kbps{$total_user_band_kbs}</td>\n\t</tr>\n\t\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:22px' nowrap>{limit_by_auth_member}:</td>\n\t\t<td style='font-size:13px'>" . Field_checkbox_design("total_member_enabled", 1, $ligne["total_member_enabled"], "total_member_enabled_check()") . "</td>\n\t</tr>\t\n\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:22px'>{delay_pool_max_field}:</td>\t\n\t\t<td style='font-size:22px'>" . Field_text("total_member_max", $total_member_max, 'width:150px;font-size:22px;padding:3px') . " Kb</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:22px'>{delay_pool_param_user_limit}:</td>\t\n\t\t<td style='font-size:22px'>" . Field_text("total_member_band", $total_member_band, 'width:150px;font-size:22px;padding:3px') . " kbps{$total_member_band_kbs}</td>\n\t</tr>\t\n\t\n\t<tr>\n\t\t<td colspan=2 align='right' style='padding-top:20px'><hr>" . button($button_title, "SaveSquidBand()", 36) . "</td>\n\t</tr>\t\t\n\t</table>\n\t</div>\n\t<span id='BandExplainRuleClassText'></span>\n\t<script>\n\t\tfunction x_SaveSquidBand(obj){\n\t\t\tvar ID={$ID};\n\t\t\tvar tempvalue=obj.responseText;\n\t\t\tif(tempvalue.length>3){alert(tempvalue);return;}\n\t\t\tif(ID==0){YahooWinHide();}\n\t\t\tif(document.getElementById('tableau-bandwith-regles')){FlexReloadRulesBandwith();}\n\t\t\tif(document.getElementById('main_bandwithrule_{$ID}')){RefreshTab('main_bandwithrule_{$ID}');}\n\t\t\tif(document.getElementById('table-{$t}')){ \$('#table-{$t}').flexReload(); }\n\t\t\t\$('#flexRT{$_GET["t"]}').flexReload();\n\t\t\t\n\t\t}\t\t\t\n\t\t\t\n\t\tfunction SaveSquidBand(){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('ID','{$ID}');\n\t\t\t\n\t\t\tif(document.getElementById('enable').checked){XHR.appendData('enable',1);}else{XHR.appendData('enable',0);}\n\t\t\tXHR.appendData('rule_name',encodeURIComponent(document.getElementById('rule_name').value));\n\t\t\t\n\t\t\t\n\t\t\tif(document.getElementById('total_net_enabled').checked){XHR.appendData('total_net_enabled',1);}else{XHR.appendData('total_net_enabled',0);}\n\t\t\tXHR.appendData('total_net_max',document.getElementById('total_net_max').value);\n\t\t\tXHR.appendData('total_net_band',document.getElementById('total_net_band').value);\n\t\t\t\n\t\t\tif(document.getElementById('total_computer_enabled').checked){\n\t\t\t\tXHR.appendData('total_computer_enabled',1);}else{\n\t\t\t\tXHR.appendData('total_computer_enabled',0);\n\t\t\t}\n\t\t\tXHR.appendData('total_computer_max',document.getElementById('total_computer_max').value);\n\t\t\tXHR.appendData('total_computer_band',document.getElementById('total_computer_band').value);\n\t\t\t\n\t\t\tif(document.getElementById('total_user_enabled').checked){\n\t\t\t\tXHR.appendData('totaluserenabled',1);}\n\t\t\t\t\telse{XHR.appendData('totaluserenabled',0);\n\t\t\t}\n\t\t\tXHR.appendData('total_user_max',document.getElementById('total_user_max').value);\n\t\t\tXHR.appendData('total_user_band',document.getElementById('total_user_band').value);\t\n\n\t\t\tif(document.getElementById('total_member_enabled').checked){XHR.appendData('total_member_enabled',1);}else{XHR.appendData('total_user_enabled',0);}\n\t\t\tXHR.appendData('total_member_max',document.getElementById('total_member_max').value);\n\t\t\tXHR.appendData('total_member_band',document.getElementById('total_member_band').value);\t\t\t\t\n\t\t\tXHR.sendAndLoad('{$page}', 'POST',x_SaveSquidBand);\t\n\t\t\t}\n\t\t\t\n\t function total_net_enabled_check(){\n\t \t\tdocument.getElementById('total_net_max').disabled=true;\n\t \t\tdocument.getElementById('total_net_band').disabled=true;\n\t \t\t\n\t \t\tif(document.getElementById('total_net_enabled').checked){\n\t \t\t\tdocument.getElementById('total_net_max').disabled=false;\n\t \t\t\tdocument.getElementById('total_net_band').disabled=false;\n\t \t\t}\n\t}\n\t\n\tfunction total_computer_enabled_check(){\n\t\t\n\t\tdocument.getElementById('total_computer_max').disabled=true;\n\t\tdocument.getElementById('total_computer_band').disabled=true;\n\t\t\n\t\tif(document.getElementById('total_computer_enabled').checked){\n\t\t\tdocument.getElementById('total_computer_max').disabled=false;\n\t\t\tdocument.getElementById('total_computer_band').disabled=false;\n\t\t}\n\t}\n\t\n\tfunction total_member_enabled_check(){\n\t\tdocument.getElementById('total_member_max').disabled=true;\n\t\tdocument.getElementById('total_member_band').disabled=true;\n\t\t\n\t\tif(document.getElementById('total_member_enabled').checked){\n\t\t\tdocument.getElementById('total_member_max').disabled=false;\n\t\t\tdocument.getElementById('total_member_band').disabled=false;\n\t\t}\t\n\t}\n\t\n\tfunction total_user_enabled_check(){\n\t\t\n\t\tdocument.getElementById('total_user_max').disabled=true;\n\t\tdocument.getElementById('total_user_band').disabled=true;\n\t\t\n\t\tif(document.getElementById('total_user_enabled').checked){\n\t\t\tdocument.getElementById('total_user_max').disabled=false;\n\t\t\tdocument.getElementById('total_user_band').disabled=false;\n\t\t}\n\t}\t \n\t \n\t function BadwEnableCheck(){\n\t \tdocument.getElementById('rule_name').disabled=true;\n\t \tdocument.getElementById('total_net_enabled').disabled=true;\n\t \tdocument.getElementById('total_net_max').disabled=true;\n\t \tdocument.getElementById('total_net_band').disabled=true;\n\t \t\n\t \tdocument.getElementById('total_computer_enabled').disabled=true;\n\t \tdocument.getElementById('total_computer_max').disabled=true;\n\t \tdocument.getElementById('total_computer_band').disabled=true;\n\t \t\n\t \tdocument.getElementById('total_user_enabled').disabled=true;\n\t \tdocument.getElementById('total_user_max').disabled=true;\n\t\tdocument.getElementById('total_user_band').disabled=true;\n\n\t\t\n\t \tdocument.getElementById('total_member_enabled').disabled=true;\n\t \tdocument.getElementById('total_member_max').disabled=true;\n\t\tdocument.getElementById('total_member_band').disabled=true;\t\t\n\t\t\n\t\t\n\t \t\n\t \t\n\t \tif(document.getElementById('enable').checked){\n\t\t \tdocument.getElementById('rule_name').disabled=false;\n\t\t \tdocument.getElementById('total_net_enabled').disabled=false;\n\t\t \tdocument.getElementById('total_computer_enabled').disabled=false;\n\t\t \tdocument.getElementById('total_user_enabled').disabled=false;\n\t\t \t\n\t\t\ttotal_computer_enabled_check();\n\t\t\ttotal_net_enabled_check();\n\t\t \ttotal_computer_enabled_check();\n\t\t \ttotal_user_enabled_check();\n\t\t \ttotal_member_enabled_check();\n\t \t}\n\t \t\n\t }\n\t\t\n\n\tBadwEnableCheck();\n\t</script>\n\t"; $tpl = new templates(); echo $tpl->_ENGINE_parse_body($html); }