function installer_custom() { global $g, $fstype, $savemsg; global $select_txt, $custom_disks; if (file_exists("/tmp/.pc-sysinstall/pc-sysinstall.log")) { unlink("/tmp/.pc-sysinstall/pc-sysinstall.log"); } $disks = installer_find_all_disks(); // Pass size of disks down to javascript. $disk_sizes_js_txt = "var disk_sizes = new Array();\n"; foreach ($disks as $disk) { $disk_sizes_js_txt .= "disk_sizes['{$disk['disk']}'] = '{$disk['size']}';\n"; } head_html(); body_html(); page_table_start($g['product_name'] . " installer - Customize disk(s) layout"); echo <<<EOF \t\t<script type="text/javascript"> \t\t\tArray.prototype.in_array = function(p_val) { \t\t\t\tfor(var i = 0, l = this.length; i < l; i++) { \t\t\t\t\tif(this[i] == p_val) { \t\t\t\t\t\treturn true; \t\t\t\t\t} \t\t\t\t} \t\t\t\treturn false; \t\t\t} \t\t\tfunction row_helper_dynamic_custom() { \t\t\t\tvar totalsize = 0; \t\t\t\t{$disk_sizes_js_txt} \t\t\t\t// Run through all rows and process data \t\t\t\tfor(var x = 0; x<99; x++) { //optimize me better \t\t\t\t\tif(\$('#fstype' + x).length) { \t\t\t\t\t\tif(\$('#size' + x).val() == '') \t\t\t\t\t\t\t\$('#size' + x).val(disk_sizes[\$('disk' + x).value]); \t\t\t\t\t\tvar fstype = \$('#fstype' + x).val(); \t\t\t\t\t\tif(fstype.substring(fstype.length - 4) == ".eli") { \t\t\t\t\t\t\t\$('#encpass' + x).prop('disabled',false); \t\t\t\t\t\t\tif(!encryption_warning_shown) { \t\t\t\t\t\t\t\talert('NOTE: If you define a disk encryption password you will need to enter it on *EVERY* bootup!'); \t\t\t\t\t\t\t\tencryption_warning_shown = true; \t\t\t\t\t\t\t} \t\t\t\t\t\t} else { \t\t\t\t\t\t\t\$('#encpass' + x).prop('disabled',true); \t\t\t\t\t\t} \t\t\t\t\t} \t\t\t\t\t// Calculate size allocations \t\t\t\t\tif(\$('#size' + x).length) { \t\t\t\t\t\tif(parseInt(\$('#size' + x).val()) > 0) \t\t\t\t\t\t\ttotalsize += parseInt(\$('#size' + x).val()); \t\t\t\t\t} \t\t\t\t} \t\t\t\t// If the totalsize element exists, set it and disable \t\t\t\tif(\$('#totalsize').length) { \t\t\t\t\tif(\$('#totalsize').val() != totalsize) { \t\t\t\t\t\t// When size allocation changes, draw attention. \t\t\t\t\t\tjQuery('#totalsize').effect('highlight'); \t\t\t\t\t\t\$('#totalsize').val(totalsize); \t\t\t\t\t} \t\t\t\t\t\$('#totalsize').prop('disabled',true); \t\t\t\t} \t\t\t\tif(\$('#disktotals').length) { \t\t\t\t\tvar disks_seen = new Array(); \t\t\t\t\tvar tmp_sizedisks = 0; \t\t\t\t\tvar disksseen = 0; \t\t\t\t\tfor(var xx = 0; xx<99; xx++) { \t\t\t\t\t\tif(\$('#disk' + xx).length) { \t\t\t\t\t\t\tif(!disks_seen.in_array(\$('#disk' + xx).val())) { \t\t\t\t\t\t\t\ttmp_sizedisks += parseInt(disk_sizes[\$('#disk' + xx).val()]); \t\t\t\t\t\t\t\tdisks_seen[disksseen] = \$('#disk' + xx).val(); \t\t\t\t\t\t\t\tdisksseen++; \t\t\t\t\t\t\t} \t\t\t\t\t\t} \t\t\t\t\t\$('#disktotals').val(tmp_sizedisks); \t\t\t\t\t\$('#disktotals').prop('disabled',true); \t\t\t\t\t\$('#disktotals').css('color','#000000'); \t\t\t\t\tvar remaining = parseInt(\$('#disktotals').val()) - parseInt(\$('#totalsize').val()); \t\t\t\t\t\tif(remaining == 0) { \t\t\t\t\t\t\tif(\$('#totalsize').length) \t\t\t\t\t\t\t\t\$('#totalsize').css({ \t\t\t\t\t\t\t\t\t'background':'#00FF00', \t\t\t\t\t\t\t\t\t'color':'#000000' \t\t\t\t\t\t\t\t}); \t\t\t\t\t\t} else { \t\t\t\t\t\t\tif(\$('#totalsize').length) \t\t\t\t\t\t\t\t\$('#totalsize').css({ \t\t\t\t\t\t\t\t\t'background':'#FFFFFF', \t\t\t\t\t\t\t\t\t'color':'#000000' \t\t\t\t\t\t\t\t}); \t\t\t\t\t\t} \t\t\t\t\t\tif(parseInt(\$('#totalsize').val()) > parseInt(\$('#disktotals').val())) { \t\t\t\t\t\t\tif(\$('#totalsize')) \t\t\t\t\t\t\t\t\$('#totalsize').css({ \t\t\t\t\t\t\t\t\t'background':'#FF0000', \t\t\t\t\t\t\t\t\t'color':'#000000' \t\t\t\t\t\t\t\t});\t\t\t\t\t\t\t \t\t\t\t\t\t} \t\t\t\t\t\tif(\$('#availalloc').length) { \t\t\t\t\t\t\t\$('#availalloc').prop('disabled',true); \t\t\t\t\t\t\t\$('#availalloc').val(remaining); \t\t\t\t\t\t\t\t\$('#availalloc').css({ \t\t\t\t\t\t\t\t\t'background':'#FFFFFF', \t\t\t\t\t\t\t\t\t'color':'#000000' \t\t\t\t\t\t\t\t});\t\t\t\t\t\t\t \t\t\t\t\t\t} \t\t\t\t\t} \t\t\t\t} \t\t\t} \t\t</script> \t\t<script type="text/javascript" src="/javascript/row_helper_dynamic.js"></script> \t\t<script type="text/javascript"> \t\t\t// Setup rowhelper data types \t\t\trowname[0] = "mountpoint"; \t\t\trowtype[0] = "textbox"; \t\t\trowsize[0] = "8"; \t\t\trowname[1] = "fstype"; \t\t\trowtype[1] = "select"; \t\t\trowsize[1] = "1"; \t\t\trowname[2] = "disk"; \t\t\trowtype[2] = "select"; \t\t\trowsize[2] = "1"; \t\t\trowname[3] = "size"; \t\t\trowtype[3] = "textbox"; \t\t\trowsize[3] = "8"; \t\t\trowname[4] = "encpass"; \t\t\trowtype[4] = "textbox"; \t\t\trowsize[4] = "8"; \t\t\tfield_counter_js = 5; \t\t\trows = 1; \t\t\ttotalrows = 1; \t\t\tloaded = 1; \t\t\trowhelper_onChange = \t" onChange='javascript:row_helper_dynamic_custom()' "; \t\t\trowhelper_onDelete = \t"row_helper_dynamic_custom(); "; \t\t\trowhelper_onAdd = \t\t"row_helper_dynamic_custom();"; \t\t</script> \t\t<form action="installer.php" method="post"> \t\t\t<input type="hidden" name="state" value="verify_before_install"> \t\t\t<div id="mainlevel"> \t\t\t\t<center> \t\t\t\t<table width="100%" border="0" cellpadding="5" cellspacing="0"> \t\t\t \t\t<tr> \t\t\t \t\t<td> \t\t\t\t\t\t\t<center> \t\t\t\t\t\t\t<div id="mainarea"> \t\t\t\t\t\t\t\t<center> \t\t\t\t\t\t\t\t<table width="100%" border="0" cellpadding="5" cellspacing="5"> \t\t\t\t\t\t\t\t\t<tr> \t\t\t \t\t\t\t\t\t<td> \t\t\t\t\t\t\t\t\t\t\t<div id="pfsenseinstaller"> \t\t\t\t\t\t\t\t\t\t\t\t<center> \t\t\t\t\t\t\t\t\t\t\t\t<div id='loadingdiv'> \t\t\t\t\t\t\t\t\t\t\t\t\t<table> \t\t\t\t\t\t\t\t\t\t\t\t\t\t<tr> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td valign="center"> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img src="/themes/{$g['theme']}/images/misc/loader.gif"> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</td> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td valign="center"> \t\t\t\t\t\t\t\t\t\t\t\t\t\t \t\t Probing disks, please wait... \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</td> \t\t\t\t\t\t\t\t\t\t\t\t\t\t</tr> \t\t\t\t\t\t\t\t\t\t\t\t\t</table> \t\t\t\t\t\t\t\t\t\t\t\t</div> EOF; ob_flush(); // Read bootmanager setting from disk if found if (file_exists("/tmp/webInstaller_disk_bootmanager.txt")) { $bootmanager = unserialize(file_get_contents("/tmp/webInstaller_disk_bootmanager.txt")); } if ($bootmanager == "none") { $noneselected = " SELECTED"; } if ($bootmanager == "bsd") { $bsdeselected = " SELECTED"; } if (!$disks) { $custom_txt = gettext("ERROR: Could not find any suitable disks for installation."); } else { // Prepare disk selection dropdown $custom_txt = <<<EOF \t\t\t\t\t\t\t\t\t\t\t\t<center> \t\t\t\t\t\t\t\t\t\t\t\t<table> \t\t\t\t\t\t\t\t\t\t\t\t<tr> \t\t\t\t\t\t\t\t\t\t\t\t\t<td align='right'> \t\t\t\t\t\t\t\t\t\t\t\t\t\tBoot manager: \t\t\t\t\t\t\t\t\t\t\t\t\t</td> \t\t\t\t\t\t\t\t\t\t\t\t\t<td> \t\t\t\t\t\t\t\t\t\t\t\t\t\t<select name='bootmanager'> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<option value='none' {$noneselected}> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tNone \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</option> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<option value='bsd' {$bsdeselected}> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tBSD \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</option> \t\t\t\t\t\t\t\t\t\t\t\t\t\t</select> \t\t\t\t\t\t\t\t\t\t\t\t\t</td> \t\t\t\t\t\t\t\t\t\t\t\t</tr> \t\t\t\t\t\t\t\t\t\t\t\t</table> \t\t\t\t\t\t\t\t\t\t\t\t<hr> \t\t\t\t\t\t\t\t\t\t\t\t<table id='maintable'><tbody> \t\t\t\t\t\t\t\t\t\t\t\t<tr> \t\t\t\t\t\t\t\t\t\t\t\t\t<td align="middle"> \t\t\t\t\t\t\t\t\t\t\t\t\t\t<b>Mount</b> \t\t\t\t\t\t\t\t\t\t\t\t\t</td> \t\t\t\t\t\t\t\t\t\t\t\t\t<td align='middle'> \t\t\t\t\t\t\t\t\t\t\t\t\t\t<b>Filesysytem</b> \t\t\t\t\t\t\t\t\t\t\t\t\t</td> \t\t\t\t\t\t\t\t\t\t\t\t\t<td align="middle"> \t\t\t\t\t\t\t\t\t\t\t\t\t\t<b>Disk</b> \t\t\t\t\t\t\t\t\t\t\t\t\t</td> \t\t\t\t\t\t\t\t\t\t\t\t\t<td align="middle"> \t\t\t\t\t\t\t\t\t\t\t\t\t\t<b>Size</b> \t\t\t\t\t\t\t\t\t\t\t\t\t</td> \t\t\t\t\t\t\t\t\t\t\t\t\t<td align="middle"> \t\t\t\t\t\t\t\t\t\t\t\t\t\t<b>Encryption password</b> \t\t\t\t\t\t\t\t\t\t\t\t\t</td> \t\t\t\t\t\t\t\t\t\t\t\t\t<td> \t\t\t\t\t\t\t\t\t\t\t\t\t\t \t\t\t\t\t\t\t\t\t\t\t\t\t</td> \t\t\t\t\t\t\t\t\t\t\t\t</tr> \t\t\t\t\t\t\t\t\t\t\t\t<tr> EOF; // Calculate swap disk sizes $memory = get_memory(); $swap_size = $memory[0] * 2; $first_disk = trim(installer_find_first_disk()); $disk_info = pcsysinstall_get_disk_info($first_disk); $size = $disk_info['size']; $first_disk_size = $size - $swap_size; // Debugging // echo "\n\n<!-- $first_disk - " . print_r($disk_info, true) . " - $size - $first_disk_size -->\n\n"; // Check to see if a on disk layout exists if (file_exists("/tmp/webInstaller_disk_layout.txt")) { $disks_restored = unserialize(file_get_contents("/tmp/webInstaller_disk_layout.txt")); $restored_layout_from_file = true; $restored_layout_txt = "<br />* The previous disk layout was restored from a previous session"; } // If we restored disk layout(s) from a file then build the rows if ($restored_layout_from_file == true) { $diskcounter = 0; foreach ($disks_restored as $dr) { $custom_txt .= return_rowhelper_row("{$diskcounter}", $dr['mountpoint'], $dr['fstype'], $dr['disk'], $dr['size'], $dr['encpass']); $diskcounter++; } } else { // Construct the default rows that outline the disks configuration. $custom_txt .= return_rowhelper_row("0", "/", "UFS+S", $first_disk, "{$first_disk_size}", ""); $custom_txt .= return_rowhelper_row("1", "none", "SWAP", $first_disk, "{$swap_size}", ""); } // tfoot and tbody are used by rowhelper $custom_txt .= "</tr>"; $custom_txt .= "<tfoot></tfoot></tbody>"; // Total allocation box $custom_txt .= "<tr><td></td><td></td><td align='right'>Total allocated:</td><td><input style='border:0px; background-color: #FFFFFF;' size='8' id='totalsize' name='totalsize'></td>"; // Add row button $custom_txt .= "</td><td> </td><td>"; $custom_txt .= "<div id=\"addrowbutton\">"; $custom_txt .= "<a onclick=\"javascript:addRowTo('maintable', 'formfldalias'); return false;\" href=\"#\">"; $custom_txt .= "<img border=\"0\" src=\"/themes/{$g['theme']}/images/icons/icon_plus.gif\" alt=\"\" title=\"add another entry\" /></a>"; $custom_txt .= "</div>"; $custom_txt .= "</td></tr>"; // Disk capacity box $custom_txt .= "<tr><td></td><td></td><td align='right'>Disk(s) capacity total:</td><td><input style='border:0px; background-color: #FFFFFF;' size='8' id='disktotals' name='disktotals'></td></tr>"; // Remaining allocation box $custom_txt .= "<tr><td></td><td></td><td align='right'>Available space for allocation:</td><td><input style='border:0px; background-color: #FFFFFF;' size='8' id='availalloc' name='availalloc'></td></tr>"; $custom_txt .= "</table>"; $custom_txt .= "<script type=\"text/javascript\">row_helper_dynamic_custom();</script>"; } echo <<<EOF \t\t\t\t\t\t\t\t\t\t\t\t<tr> \t\t\t\t\t\t\t\t\t\t\t\t\t<td colspan='4'> \t\t\t\t\t\t\t\t\t\t\t\t\t<script type="text/javascript"> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\$('#loadingdiv').css('visibility','hidden'); \t\t\t\t\t\t\t\t\t\t\t\t\t</script> \t\t\t\t\t\t\t\t\t\t\t\t\t<div id='contentdiv' style="display:none;"> \t\t\t\t\t\t\t\t\t\t\t\t\t\t<p/> \t\t\t\t\t\t\t\t\t\t\t\t\t\t{$custom_txt}<p/> \t\t\t\t\t\t\t\t\t\t\t\t\t\t<hr><p/> \t\t\t\t\t\t\t\t\t\t\t\t\t\t<input type="button" value="Cancel" onClick="javascript:document.location='/installer/installer.php';">   \t\t\t\t\t\t\t\t\t\t\t\t\t\t<input type="submit" value="Next"> \t\t\t\t\t\t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t\t\t\t\t\t<script type="text/javascript"> \t\t\t\t\t\t\t\t\t\t\t\t\t\tvar encryption_warning_shown = false; \t\t\t\t\t\t\t\t\t\t\t\t\t\t\$('#contentdiv').fadeIn(); \t\t\t\t\t\t\t\t\t\t\t\t\t\trow_helper_dynamic_custom(); \t\t\t\t\t\t\t\t\t\t\t\t\t</script> \t\t\t\t\t\t\t\t\t\t\t\t</center> \t\t\t\t\t\t\t\t\t\t\t\t</td></tr> \t\t\t\t\t\t\t\t\t\t\t\t</table> \t\t\t\t\t\t\t\t\t\t\t</div> \t\t\t \t\t\t\t\t\t</td> \t\t\t\t\t\t\t\t\t</tr> \t\t\t\t\t\t\t\t</table> \t\t\t\t\t\t\t\t</center> \t\t\t\t\t\t\t\t<span class="vexpl"> \t\t\t\t\t\t\t\t\t<span class="red"> \t\t\t\t\t\t\t\t\t\t<strong> \t\t\t\t\t\t\t\t\t\t\tNOTES: \t\t\t\t\t\t\t\t\t\t</strong> \t\t\t\t\t\t\t\t\t</span> \t\t\t\t\t\t\t\t\t<br />* Sizes are in megabytes. \t\t\t\t\t\t\t\t\t<br />* Mount points named /conf are not allowed. Use /cf if you want to make a configuration slice/mount. \t\t\t\t\t\t\t\t\t{$restored_layout_txt} \t\t\t\t\t\t\t\t</span> \t\t\t\t\t\t\t\t</strong> \t\t\t\t\t\t\t</div> \t\t\t\t\t\t</td> \t\t\t\t\t</tr> \t\t\t\t</table> \t\t\t</div> \t\t\t</center> \t\t\t<script type="text/javascript"> \t\t\t<!-- \t\t\t\tnewrow[1] = "{$select_txt}"; \t\t\t\tnewrow[2] = "{$custom_disks}"; \t\t\t--> \t\t\t</script> \t\t\t EOF; page_table_end(); end_html(); }
function get_show_arr($now_get, $success_count, $get_count, $all_get_time = 0, $end = 1) { $pro = ceil(100 * ($success_count / $get_count)); if ($pro == 101 || $pro > 101) { return FALSE; } if ($end == 1) { $get_time = d_e(0); } $all_get_time += $get_time; $avg_get_time = $success_count > 0 ? $all_get_time / $success_count : 0; $wait_count = $get_count - $success_count; $wait_time = $avg_get_time * $wait_count; if (function_exists('php_set')) { $memory = 100 * (get_memory() / php_set('memory_limit')); $memory = $memory || $memory != 0 ? sprintf('%.0f%%', $memory) : milu_lang('un_know'); } $show_arr = array('pro' => $pro, 'wait_time' => $wait_time, 'memory' => $memory, 'wait_count' => $wait_count, 'now' => $now_get, 'all_get_time' => $all_get_time); return $show_arr; }
function run_check($file_services, $file_configuration, &$data_autoconf, $binary, $binary_stats, $file_report, $var_dir, $nb_check, $time) { if (file_put_contents($file_services, $data_autoconf) === FALSE) { exit('error: file_put_contents failed' . NL); } my_system('rm -rf ' . $var_dir); @mkdir($var_dir); @mkdir($var_dir . '/rw'); @mkdir($var_dir . '/spool'); system($binary . ' ' . $file_configuration . ' > /dev/null 2>&1 &'); sleep(1); if (my_system('ps aux | grep ' . basename($binary) . ' | grep -v grep') == '') { exit('error: ' . basename($binary) . ' not running' . NL); } for ($i = 0; $i < $time; $i += 5 * 60) { $memory = get_memory($binary); $loadavg = get_loadavg(); $latency = get_latency($binary_stats); $line = $nb_check . ' ' . $memory . ' ' . $loadavg['load5'] . ' ' . $loadavg['load15'] . ' ' . $latency . ' ' . time() . NL; if (file_put_contents($file_report, $line, FILE_APPEND) === FALSE) { exit('error: file_put_contents failed' . NL); } sleep(5 * 60); } my_kill($binary); return $latency; }
?> </span> </td> </tr> <tr> <td class='summaryKey'> Current Date </td> <td class='summaryValue'><span class='sleft'><?php echo get_datetime(); ?> </span> </td> </tr> </table> <?php echo "<h3>Memory Information</h3>"; $meminfo = get_memory(); ?> <table class='summarySection'> <tr> <td class='summaryKey'> Mem. Total </td> <td class='summaryValue'><span class='sleft'><?php echo convert_ToMB($meminfo['MemTotal']); ?> </span> </td> </tr> <tr> <td class='summaryKey'> Mem. Free </td> <td class='summaryValue'><span class='sleft'><?php echo convert_ToMB($meminfo['MemFree']);
<tr> <td><img src="icons/Ekisho-Deep-Ocean-HD-1-icon.png" alt="HDD"/>Server Disk Usage :</td> <td><?php if (isset($ch5) && $ch5 == 'selected') { echo get_hdd(); } else { echo "Not selected"; } ?> </td> </tr> <tr> <td><img src="icons/monitor-icon.png" alt="HDD" />Memory Usage :</td> <td><?php if (isset($ch6) && $ch6 == 'selected') { echo get_memory(); echo '%'; } else { echo "Not selected"; } ?> </td> </tr> <tr> <td><img src="icons/Globe-icon.png" alt="Ping"/>Your ping to this server :</td> <td><?php if (isset($ch7) && $ch7 == 'selected') { echo get_ping(); } else { echo "Not selected"; }
function start($skipGrant = false) { if (is_file("/etc/artica-postfix/FROM_ISO")) { if (!is_file("/etc/artica-postfix/artica-iso-setup-launched")) { return; } } $unix = new unix(); $pidfile = "/etc/artica-postfix/pids/squiddbstart.pid"; $sock = new sockets(); $WORKDIR = $sock->GET_INFO("SquidStatsDatabasePath"); if ($WORKDIR == null) { $WORKDIR = "/opt/squidsql"; } $SERV_NAME = "squid-db"; $pid = $unix->get_pid_from_file($pidfile); $sock = new sockets(); $nohup = $unix->find_program("nohup"); $php5 = $unix->LOCATE_PHP5_BIN(); $lnbin = $unix->find_program("ln"); if (!$GLOBALS["FORCE"]) { if (!$GLOBALS["NOPID"]) { if ($unix->process_exists($pid, basename(__FILE__))) { $time = $unix->PROCCESS_TIME_MIN($pid); if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: Starting Task Already running PID {$pid} since {$time}mn\n"; } return; } } } @file_put_contents($pidfile, getmypid()); $GetStartedValues = GetStartedValues(); $sock = new sockets(); $ProxyUseArticaDB = $sock->GET_INFO("ProxyUseArticaDB"); $DisableArticaProxyStatistics = $sock->GET_INFO("DisableArticaProxyStatistics"); if (!is_numeric($ProxyUseArticaDB)) { $ProxyUseArticaDB = 0; } if (!is_numeric($DisableArticaProxyStatistics)) { $DisableArticaProxyStatistics = 0; } if (!is_dir($WORKDIR)) { @mkdir($WORKDIR, 0755, true); } if ($ProxyUseArticaDB == 0) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]:{$SERV_NAME} is disabled...\n"; } stop(); return; } $mysqld = $unix->find_program("mysqld"); if (!is_file($mysqld)) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]:{$SERV_NAME} is not installed...\n"; } return; } $pid = SQUIDDB_PID(); if ($unix->process_exists($pid)) { $time = $unix->PROCCESS_TIME_MIN($pid); if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$SERV_NAME} MySQL Database Engine already running pid {$pid} since {$time}mn\n"; } return; } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$SERV_NAME} writing init.d\n"; } initd(); $memory = get_memory(); $swap = get_swap(); if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$SERV_NAME} Server available memory `{$memory}MB`\n"; } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$SERV_NAME} Server available swap `{$swap}MB`\n"; } $SquidDBTuningParameters = unserialize(base64_decode($sock->GET_INFO("SquidDBTuningParameters"))); $ListenPort = $SquidDBTuningParameters["ListenPort"]; if (!is_numeric($ListenPort)) { $ListenPort = 0; } if ($ListenPort == 0) { $ListenPort = rand(8900, 45890); $SquidDBTuningParameters["ListenPort"] = $ListenPort; $sock->SET_INFO("SquidDBTuningParameters", base64_encode(serialize($SquidDBTuningParameters))); } @mkdir($WORKDIR, 0755, true); $mysqlserv = new mysql_services(); $mysqlserv->WORKDIR = $WORKDIR; $mysqlserv->MYSQL_PID_FILE = "/var/run/squid-db.pid"; $mysqlserv->MYSQL_SOCKET = "/var/run/mysqld/squid-db.sock"; $mysqlserv->SERV_NAME = $SERV_NAME; $mysqlserv->TokenParams = "SquidDBTuningParameters"; $mysqlserv->INSTALL_DATABASE = true; $mysqlserv->MYSQL_BIN_DAEMON_PATH = $unix->find_program("mysqld"); //$mysqlserv->MYSQL_ERRMSG=$GLOBALS["MYSQL_ERRMSG"]; $mysqlserv->InnoDB = false; $cmdline = $mysqlserv->BuildParams(); $CREATEDB = false; if (!is_file("{$WORKDIR}/my.cnf")) { @file_put_contents("{$WORKDIR}/my.cnf", "\n"); } if (!is_file("{$WORKDIR}/bin/my_print_defaults")) { $my_print_defaults = $unix->find_program("my_print_defaults"); shell_exec("{$lnbin} -s {$my_print_defaults} {$WORKDIR}/bin/my_print_defaults"); } if (!is_file("{$WORKDIR}/data/mysql/user.MYD")) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$SERV_NAME} Installing defaults databases, Please Wait...\n"; } install_db($WORKDIR); $CREATEDB = true; } $topCopyMysql["host.frm"] = true; $topCopyMysql["host.MYD"] = true; $topCopyMysql["host.MYI"] = true; $topCopyMysql["servers.frm"] = true; $topCopyMysql["servers.MYD"] = true; $topCopyMysql["servers.MYI"] = true; $MYSQL_DATA_DIR = $unix->MYSQL_DATA_DIR(); $topCopyMysqlForce["tables_priv.frm"] = true; $topCopyMysqlForce["tables_priv.MYD"] = true; $topCopyMysqlForce["tables_priv.MYI"] = true; $topCopyMysqlForce["columns_priv.frm"] = true; $topCopyMysqlForce["columns_priv.MYD"] = true; $topCopyMysqlForce["columns_priv.MYI"] = true; $topCopyMysqlForce["procs_priv.frm"] = true; $topCopyMysqlForce["procs_priv.MYD"] = true; $topCopyMysqlForce["procs_priv.MYI"] = true; $topCopyMysqlForce["plugin.frm"] = true; $topCopyMysqlForce["plugin.MYD"] = true; $topCopyMysqlForce["plugin.MYI"] = true; $topCopyMysqlForce["user.frm"] = true; $topCopyMysqlForce["user.MYD"] = true; $topCopyMysqlForce["user.MYI"] = true; $topCopyMysqlForce["db.frm"] = true; $topCopyMysqlForce["db.MYD"] = true; $topCopyMysqlForce["db.MYI"] = true; $ToCopyForce = false; while (list($filename, $ligne) = each($topCopyMysql)) { if (!is_file("{$WORKDIR}/data/mysql/{$filename}")) { $ToCopyForce = true; if (is_file("{$MYSQL_DATA_DIR}/mysql/{$filename}")) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: Installing {$filename}\n"; } @copy("{$MYSQL_DATA_DIR}/mysql/{$filename}", "{$WORKDIR}/data/mysql/{$filename}"); $CREATEDB = true; } } } while (list($filename, $ligne) = each($topCopyMysqlForce)) { if (!is_file("{$WORKDIR}/data/mysql/{$filename}")) { if (is_file("{$MYSQL_DATA_DIR}/mysql/{$filename}")) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: Installing {$filename}\n"; } @copy("{$MYSQL_DATA_DIR}/mysql/{$filename}", "{$WORKDIR}/data/mysql/{$filename}"); } } } @mkdir("{$WORKDIR}/share/mysql/english", 0755, true); $Get_errmsgsys = Get_errmsgsys(); if (!is_file("{$WORKDIR}/share/mysql/english/errmsg.sys")) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: Creating errmsg.sys\n"; } ini_set('error_reporting', E_ALL); ini_set('error_prepend_string', null); ini_set('error_append_string', null); if (is_file($Get_errmsgsys)) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: copy {$Get_errmsgsys} -> {$WORKDIR}/share/mysql/english/errmsg.sys\n"; } copy(Get_errmsgsys(), "{$WORKDIR}/share/mysql/english/errmsg.sys"); } else { file_put_contents("{$WORKDIR}/share/mysql/english/errmsg.sys", "\n"); } } else { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: errmsg.sys OK\n"; } } $TMP = $unix->FILE_TEMP(); $nohup = $unix->find_program("nohup"); if ($GLOBALS["VERBOSE"]) { echo $cmdline . "\n"; } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: Starting MySQL daemon ({$SERV_NAME})\n"; } @unlink("{$WORKDIR}/error.log"); shell_exec("{$nohup} {$cmdline} >{$TMP} 2>&1 &"); sleep(1); for ($i = 0; $i < 5; $i++) { $pid = SQUIDDB_PID(); if ($unix->process_exists($pid)) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: MySQL daemon ({$SERV_NAME}) started pid .{$pid}..\n"; } break; } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: MySQL daemon wait {$i}/5\n"; } sleep(1); } sleep(1); $pid = SQUIDDB_PID(); if (!$unix->process_exists($pid)) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: MySQL daemon ({$SERV_NAME}) failed to start\n"; } if (is_file($TMP)) { $f = explode("\n", @file_get_contents($TMP)); while (list($num, $ligne) = each($f)) { if (trim($ligne) == null) { continue; } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$ligne}\n"; } } } $f = explode("\n", @file_get_contents("{$WORKDIR}/error.log")); while (list($num, $ligne) = each($f)) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: MySQL Results \"{$ligne}\"\n"; } if (preg_match("#Incorrect information in file: './mysql/proxies_priv.frm'#", $ligne)) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: remove MySQL tables and install again...\n"; } shell_exec("/bin/rm -rf {$WORKDIR}/data/mysql/*"); shell_exec("{$nohup} {$php5} " . __FILE__ . " --start --recall >/dev/ null 2>&1 &"); return; } } } else { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: MySQL daemon ({$SERV_NAME}) success\n"; } if ($CREATEDB) { $q = new mysql_squid_builder(); $q->CheckTables(); } $q = new mysql_squid_builder(); $q->MEMORY_TABLES_RESTORE(); } if (!$unix->process_exists($pid)) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$cmdline}\n"; } } $unix->THREAD_COMMAND_SET($unix->LOCATE_PHP5_BIN() . " " . __FILE__ . " --databasesize"); }
function get_pick_status($end = 0) { $get_count = $this->get_pick_count(); if ($end == 1) { $get_time = d_e(0, 'run'); $this->all_get_time += $get_time; $this->pick_cache_data['all_get_time'] = $this->all_get_time; } if ($get_count) { $pro = ceil(100 * ($this->i / $get_count)); if ($pro == 101 || $pro > 101) { return; } $avg_get_time = $this->all_get_time / $this->i; $wait_count = $get_count - $this->i; $wait_time = $avg_get_time * $wait_count; } else { $pro = $wait_time = $wait_count = milu_lang('un_know'); } if (function_exists('php_set')) { $memory = 100 * (get_memory() / php_set('memory_limit')); $memory = $memory || $memory != 0 ? sprintf('%.0f%%', $memory) : milu_lang('un_know'); } $wait_time = is_numeric($wait_time) ? round($wait_time) : $wait_time; $this->status_arr = array('pro' => $pro, 'wait_time' => $wait_time, 'memory' => $memory, 'wait_count' => $wait_count, 'now' => $this->i); $this->status_arr = array_merge($this->status_arr, $this->msg_args); }
set_CatPageRequest(); # session setzen mit der vorschau vom editor aus dem admin if (DRAFT and getRequestValue('prevcontentadmin', 'post', false)) { unset($_SESSION['prevcontentadmin']); $tmp = getRequestValue('prevcontentadmin', 'post', false); if ($tmp != "prevcontentadminthisclear") { $_SESSION['prevcontentadmin'][CAT_REQUEST][PAGE_REQUEST] = $tmp; } exit("true"); } elseif (!DRAFT) { unset($_SESSION['prevcontentadmin']); } // Dann: HTML-Template einlesen und mit Inhalt fuellen readTemplate($template, $pagecontent); if (strpos($HTML, "<!--{MEMORYUSAGE}-->") > 1) { $HTML = str_replace("<!--{MEMORYUSAGE}-->", get_memory(), $HTML); } if (strpos($HTML, "<!--{EXECUTETIME}-->") > 1) { $HTML = str_replace("<!--{EXECUTETIME}-->", get_executTime($start_time), $HTML); } // Zum Schluß: Ausgabe des fertigen HTML-Dokuments echo $HTML; function get_executTime($start_time) { if (!function_exists('gettimeofday')) { return NULL; } list($usec, $sec) = explode(" ", microtime()); if ($start_time === false) { return (double) $usec + (double) $sec; }