Exemplo n.º 1
0
function add_new_disk_popup()
{
    $t = time();
    $page = CurrentPageName();
    $squid = new squidbee();
    $tpl = new templates();
    $sock = new sockets();
    $caches_types = unserialize(base64_decode($sock->getFrameWork("squid.php?caches-types=yes")));
    $caches_types[null] = '{select}';
    unset($caches_types["rock"]);
    $type = $tpl->_ENGINE_parse_body(Field_array_Hash($caches_types, "cache_type-{$t}", "aufs", "CheckCachesTypes()", null, 0, "font-size:16px;padding:3px"));
    $WARN_OPE_RESTART_SQUID_ASK = $tpl->javascript_parse_text("{WARN_OPE_RESTART_SQUID_ASK}");
    $currentsize = Calculate_maxcachessize();
    $maxCacheSizeInt = 0;
    $maxCacheSize = 0;
    $BUTTON_NAME = "{add}";
    $DefaultmaxCacheSize = round($maxCacheSize / 4, 1);
    $NextCache = count($squid->cache_list) + 1;
    $defaultCachedir = "/home/squid/cache/squid0{$NextCache}";
    $cachedirtext = "\n\t\t<tr>\n\t\t<td class=legend style='font-size:16px' nowrap>{directory}:</td>\n\t\t<td>" . Field_text("cache_directory-{$t}", $defaultCachedir, "width:270px;font-size:16px;padding:3px", null, "Slider{$t}()") . "</td>\n\t\t<td>" . button("{browse}...", "Loadjs('SambaBrowse.php?no-shares=yes&field=cache_directory-{$t}&functionAfter=Slider{$t}')", 12) . "</td>\n\t\t</tr>";
    $SliderDef = 1;
    $cache_dir_level1_def = 16;
    $LockOthers = 0;
    if (isset($_GET["chdef"])) {
        $DF = unserialize(base64_decode($sock->getFrameWork("system.php?DF_SATUS_K=" . urlencode($squid->CACHE_PATH))));
        $BUTTON_NAME = "{apply}";
        $SIZE = round($DF["SIZE"] / 1024 / 1024);
        $maxCacheSize = round($SIZE * 0.9);
        $cachedirtext = "<tr>\n\t\t<td class=legend style='font-size:16px' nowrap>{directory}:</td>\n\t\t<td><strong style='font-size:14px'>{$squid->CACHE_PATH}</strong>" . Field_hidden("cache_directory-{$t}", $squid->CACHE_PATH) . "</td>\n\t\t<td>&nbsp;</td>\n\t\t</tr>";
        if ($squid->CACHE_TYPE == null) {
            $squid->CACHE_TYPE = "aufs";
        }
        $type = $tpl->_ENGINE_parse_body(Field_array_Hash($caches_types, "cache_type-{$t}", $squid->CACHE_TYPE, "CheckCachesTypes()", null, 0, "font-size:16px;padding:3px"));
        $SliderDef = round($squid->CACHE_SIZE / 1000);
        $DefaultmaxCacheSize = $squid->CACHE_SIZE / 1000;
        $XHRADD = "XHR.appendData('DEFAULT_CACHE_SAVE_TRUE','OK');";
        $LockOthers = 1;
    }
    $html = "\t<div id='waitcache-{$t}'></div>\n\t\n\t<div style='width:98%' class=form>\n\t<table style='width:99%'>\n\t\t{$cachedirtext}\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:16px' nowrap>{type}:</td>\n\t\t\t<td>{$type}</td>\n\t\t\t<td>&nbsp;</td>\n\t\t\t<td>&nbsp;</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:16px;;vertical-align:middle' nowrap>{cache_size}:</td>\n\t\t\t<td style='font-size:16px;vertical-align:middle' width=1% >" . Field_text("squid-cache-size-{$t}", $SliderDef, "font-size:16px;width:90px", null, "Slider{$t}()", null, false, "Slider{$t}()") . "<strong style='font-size:16px'>&nbsp;G&nbsp;</td>\n\t\t\t<td style='width:1%'><div style='font-size:22px;font-weight:bold;text-align:right;letter-spacing:3px;width:220px' id='{$t}-value'>{max_size}:{$maxCacheSize}G</div></td>\n\t\t\t<td>" . help_icon('{cache_size_text}', false, 'squid.index.php') . "</td>\n\t\t</tr>\n\t\t<tr>\n\t\t<td colspan=4>\n\t\t\t\t\t\n\t\t\t\t\t<input type='hidden' id='{$t}-mem' value='{$SquidBoosterMem}'>\n\t\t\t\t\t<div class=explain style='font-size:13px'>{warn_calculate_nothdsize}</div></td>\t\t\n\n\t\t<tr>\n\t\t\t<td class=legend nowrap style='font-size:16px'>{cache_dir_level1}:</td>\n\t\t\t<td>" . Field_text("cache_dir_level1-{$t}", 16, 'width:50px;font-size:16px;padding:3px') . "</td>\n\t\t\t<td>&nbsp;</td>\n\t\t\t<td>" . help_icon('{cache_dir_level1_text}', false, 'squid.index.php') . "</td>\n\t\t</tr>\t\t\t\n\t\t<tr>\n\t\t\t<td class=legend nowrap style='font-size:16px'>{cache_dir_level2}:</td>\n\t\t\t<td>" . Field_text("cache_dir_level2-{$t}", 256, 'width:50px;font-size:16px;padding:3px') . "</td>\n\t\t\t<td>&nbsp;</td>\n\t\t\t<td>" . help_icon('{cache_dir_level2_text}', false, 'squid.index.php') . "</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td class=legend nowrap style='font-size:16px'>{max_objects_size}:</td>\n\t\t\t<td  style='font-size:16px'>" . Field_text("cache_maxsize-{$t}", $s->cache_list[$cache]["cache_maxsize"], 'width:50px;font-size:16px;padding:3px', null, "calculateSize()", null, false, null) . "&nbsp;Mbytes&nbsp;<span id='squid-maxsize-vals'></span></td>\n\t\t\t<td>&nbsp;</td>\n\t\t\t<td>" . help_icon('{squid_rock_maxsize}', false, 'squid.index.php') . "</td>\n\t\t</tr>\n\t\t\n\t\t<tr>\n\t\t<td align='right' colspan=4><hr>" . button($BUTTON_NAME, "AddNewCacheSave{$t}()", 18) . "</td>\n\t\t</tr>\n\t</table>\n\t</div>\n<script>\n\n\t\t\n\t\t\n\n\t\tfunction CheckCachesTypes(){\n\t\t\tcachetypes=document.getElementById('cache_type-{$t}').value;\n\t\t\tvar LockOthers={$LockOthers};\n\t\t\tif(LockOthers==1){\n\t\t\t\tdocument.getElementById('cache_dir_level2-{$t}').disabled=true;\n\t\t\t\tdocument.getElementById('cache_dir_level1-{$t}').disabled=true;\n\t\t\t\tdocument.getElementById('cache_maxsize-{$t}').disabled=true;\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\tvar x_AddNewCacheSave{$t}= function (obj) {\n\t\t\tvar results=obj.responseText;\n\t\t\tif(results.length>0){\n\t\t\t\talert(results);\n\t\t\t\tdocument.getElementById('waitcache').innerHTML='';\n\t\t\t\t}\n\t\t\tYahooWin3Hide();\n\t\t\tSaveSquid32CachesStatus();\n\t\t\tExecuteByClassName('SearchFunction');\n\t\t}\t\t\n\t\n\tfunction AddNewCacheSave{$t}(){\n\t\tif(confirm('{$WARN_OPE_RESTART_SQUID_ASK}')){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\t{$XHRADD}\n\t\t\tXHR.appendData('cache_directory',document.getElementById('cache_directory-{$t}').value);\n\t\t\tXHR.appendData('cache_type',document.getElementById('cache_type-{$t}').value);\n\t\t\tXHR.appendData('size',document.getElementById('squid-cache-size-{$t}').value);\n\t\t\tXHR.appendData('cache_dir_level1',document.getElementById('cache_dir_level1-{$t}').value);\n\t\t\tXHR.appendData('cache_dir_level2',document.getElementById('cache_dir_level2-{$t}').value);\n\t\t\tXHR.appendData('cache_maxsize',document.getElementById('cache_maxsize-{$t}').value);\n\t\t\tAnimateDiv('waitcache-{$t}');\n\t\t\tXHR.sendAndLoad('{$page}', 'POST',x_AddNewCacheSave{$t});\n\t\t\t}\n\t\t}\t\t\n\t\t\n\tfunction Slider{$t}(){\n\t\tLoadjs('{$page}?slider-t=yes&t={$t}');\n\t\n\t}\n\t\t\n\t\tCheckCachesTypes();\n\t\tSlider{$t}();\n</script>";
    echo $tpl->_ENGINE_parse_body($html);
}
Exemplo n.º 2
0
function add_new_disk_popup()
{
    $t = $_GET["t"];
    $page = CurrentPageName();
    $squid = new squidbee();
    $tpl = new templates();
    $sock = new sockets();
    $caches_types[null] = '{select}';
    $caches_types["aufs"] = "aufs";
    $caches_types["diskd"] = "diskd";
    unset($caches_types["rock"]);
    $type = $tpl->_ENGINE_parse_body(Field_array_Hash($caches_types, "cache_type-{$t}", "aufs", "CheckCachesTypes()", null, 0, "font-size:16px;padding:3px"));
    $WARN_OPE_RESTART_SQUID_ASK = $tpl->javascript_parse_text("{WARN_OPE_RESTART_SQUID_ASK}");
    $currentsize = Calculate_maxcachessize();
    $maxCacheSizeInt = 250 * 1000 - $currentsize;
    $maxCacheSize = 50;
    $DefaultmaxCacheSize = round($maxCacheSize / 4, 1);
    $NextCache = count($squid->cache_list) + 1;
    $defaultCachedir = "/home/squid/cache/squid0{$NextCache}";
    $cachedirtext = "\n\t\t<tr>\n\t\t<td class=legend style='font-size:16px' nowrap>{directory}:</td>\n\t\t<td>" . Field_text("cache_directory-{$t}", $defaultCachedir, "width:270px;font-size:16px;padding:3px") . "</td>\n\t\t<td></td>\n\t\t</tr>";
    $btname = "{add}";
    $SliderDef = 10;
    $cache_dir_level1_def = 16;
    $LockOthers = 0;
    if (isset($_GET["chdef"])) {
        $cachedirtext = "<tr>\n\t\t<td class=legend style='font-size:16px' nowrap>{directory}:</td>\n\t\t<td><strong style='font-size:14px'>{$squid->CACHE_PATH}</strong>" . Field_hidden("cache_directory-{$t}", $squid->CACHE_PATH) . "</td>\n\t\t<td>&nbsp;</td>\n\t\t</tr>";
        $btname = "{apply}";
        $type = $tpl->_ENGINE_parse_body(Field_array_Hash($caches_types, "cache_type-{$t}", $squid->CACHE_TYPE, "CheckCachesTypes()", null, 0, "font-size:16px;padding:3px"));
        $SliderDef = round($squid->CACHE_SIZE / 1000);
        $DefaultmaxCacheSize = $squid->CACHE_SIZE / 1000;
        $XHRADD = "XHR.appendData('DEFAULT_CACHE_SAVE_TRUE','OK');";
        $LockOthers = 1;
    }
    $html = "\t<div id='waitcache-{$t}'></div>\n\t<input type='hidden' name='squid-cache-size-{$t}' id='squid-cache-size-{$t}' value='10'>\n\t<table style='width:99%' class=form>\n\t\t{$cachedirtext}\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:16px' nowrap>{type}:</td>\n\t\t\t<td>{$type}</td>\n\t\t\t<td>&nbsp;</td>\n\t\t\t<td>&nbsp;</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:16px' nowrap>{cache_size}:</td>\n\t\t\t<td style='font-size:16px'><div id='slider{$t}'></div></td>\n\t\t\t<td>&nbsp;<strong style='font-size:16px' id='{$t}-value'>{$DefaultmaxCacheSize}G/{$maxCacheSize}G</strong><input type='hidden' id='{$t}-mem' value='{$SquidBoosterMem}'></td>\n\t\t\t<td>" . help_icon('{cache_size_text}', false, 'squid.index.php') . "</td>\n\t\t</tr>\n\t\t<tr>\n\t\t<td colspan=4><strong>{warn_calculate_nothdsize}</strong></td>\t\t\n\n\t\t<tr>\n\t\t\t<td class=legend nowrap style='font-size:16px'>{cache_dir_level1}:</td>\n\t\t\t<td>" . Field_text("cache_dir_level1-{$t}", 16, 'width:50px;font-size:16px;padding:3px') . "</td>\n\t\t\t<td>&nbsp;</td>\n\t\t\t<td>" . help_icon('{cache_dir_level1_text}', false, 'squid.index.php') . "</td>\n\t\t</tr>\t\t\t\n\t\t<tr>\n\t\t\t<td class=legend nowrap style='font-size:16px'>{cache_dir_level2}:</td>\n\t\t\t<td>" . Field_text("cache_dir_level2-{$t}", 256, 'width:50px;font-size:16px;padding:3px') . "</td>\n\t\t\t<td>&nbsp;</td>\n\t\t\t<td>" . help_icon('{cache_dir_level2_text}', false, 'squid.index.php') . "</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td class=legend nowrap style='font-size:16px'>{max_objects_size}:</td>\n\t\t\t<td  style='font-size:16px'>" . Field_text("cache_maxsize-{$t}", $s->cache_list[$cache]["cache_maxsize"], 'width:50px;font-size:16px;padding:3px', null, "calculateSize()", null, false, null) . "&nbsp;Mbytes&nbsp;<span id='squid-maxsize-vals'></span></td>\n\t\t\t<td>&nbsp;</td>\n\t\t\t<td>" . help_icon('{squid_rock_maxsize}', false, 'squid.index.php') . "</td>\n\t\t</tr>\n\t\t\n\t\t<tr>\n\t\t<td align='right' colspan=4><hr>" . button($btname, "AddNewCacheSave{$t}()", 14) . "</td>\n\t\t</tr>\n\t</table>\n\t\n<script>\n\t\t\$(document).ready(function(){\n\t\t\t\$('#slider{$t}').slider({ max: {$maxCacheSize},step:2,value:{$SliderDef},slide: function(e, ui) {ChangeSlideField{$t}(ui.value)},change: function(e, ui) {ChangeSlideField{$t}(ui.value);} });\n\t\t});\n\t\t\n\t\tfunction ChangeSlideField{$t}(val){\n\t\t\tvar disabled='';\n\t\t\tif(val==0){disabled='&nbsp;{$disabled}';}\n\t\t\tdocument.getElementById('{$t}-value').innerHTML=val+'G/{$maxCacheSize}G'+disabled;\n\t\t\tdocument.getElementById('squid-cache-size-{$t}').value=val;\n\t\t}\t\t\n\n\n\t\tfunction CheckCachesTypes(){\n\t\t\tcachetypes=document.getElementById('cache_type-{$t}').value;\n\t\t\tvar LockOthers={$LockOthers};\n\t\t\tif(LockOthers==1){\n\t\t\t\tdocument.getElementById('cache_dir_level2-{$t}').disabled=true;\n\t\t\t\tdocument.getElementById('cache_dir_level1-{$t}').disabled=true;\n\t\t\t\tdocument.getElementById('cache_maxsize-{$t}').disabled=true;\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\tvar x_AddNewCacheSave{$t}= function (obj) {\n\t\t\tvar results=obj.responseText;\n\t\t\tif(results.length>0){\n\t\t\t\talert(results);\n\t\t\t\tdocument.getElementById('waitcache').innerHTML='';\n\t\t\t\t}\n\t\t\tYahooWin3Hide();\n\t\t\t\$('flexRT{$t}').flexReload();\n\t\t\tRefreshTab('squid_main_caches_new');\n\t\t}\t\t\n\t\n\tfunction AddNewCacheSave{$t}(){\n\t\t\n\t\t\tvar XHR = new XHRConnection();\n\t\t\t{$XHRADD}\n\t\t\tXHR.appendData('cache_directory',document.getElementById('cache_directory-{$t}').value);\n\t\t\tXHR.appendData('cache_type',document.getElementById('cache_type-{$t}').value);\n\t\t\tXHR.appendData('size',document.getElementById('squid-cache-size-{$t}').value);\n\t\t\tXHR.appendData('cache_dir_level1',document.getElementById('cache_dir_level1-{$t}').value);\n\t\t\tXHR.appendData('cache_dir_level2',document.getElementById('cache_dir_level2-{$t}').value);\n\t\t\tXHR.appendData('cache_maxsize',document.getElementById('cache_maxsize-{$t}').value);\n\t\t\tAnimateDiv('waitcache-{$t}');\n\t\t\tXHR.sendAndLoad('{$page}', 'POST',x_AddNewCacheSave{$t});\n\t\t\t\n\t\t}\t\t\n\t\tCheckCachesTypes();\n</script>";
    echo $tpl->_ENGINE_parse_body($html);
}