示例#1
0
 function get_uploadable()
 {
     $upload_max = convert_bytes(ini_get('upload_max_filesize'));
     $post_max = convert_bytes(ini_get('post_max_size'));
     $memory_limit = convert_bytes(ini_get('memory_limit'));
     return $uploadable = floor(min($upload_max, $post_max, $memory_limit) / 1048576) . 'MB';
 }
示例#2
0
文件: jobs.php 项目: standage/xGDBvm
 $job_type = $row["job_type"];
 $program = $row["program"];
 # e.g. GTH or GSQ
 $appId = $row["softwareName"];
 # Unique name configured on configure.php
 $job_description = $row["job_URL"];
 $HPC_name = $row["HPC_name"];
 $user = $row["user"];
 $admin_email = $row["admin_email"];
 $seq_type = $row["seq_type"];
 $genome_file_size = $row["genome_file_size"];
 $genome_file_size_display = convert_bytes($genome_file_size, 0);
 $genome_segments = $row["genome_segments"];
 $split_count = $row["split_count"];
 $input_file_size = $row["input_file_size"];
 $input_file_size_display = convert_bytes($input_file_size, 0);
 $parameters = $row["parameters"];
 $requested_time = $row["requested_time"];
 $processor_count = $row["processors"];
 $memory = $row["memory"];
 $comments = $row["comments"];
 $error = $row["error"];
 # $error_display=($error=="")?"": "<br /><span class=\"warning smallerfont\">$error</span><br /><span class=\"smallerfont\">$comments</span>";
 $error_display = $error == "" ? "" : "<a name=\"uid\" class=\"help-button2\" title=\"Click '?' for status progress.\"><span class=\"warning smallerfont\">{$error}</span></a>";
 //invokes jquery dialog help
 $running_pattern = "/RUNNING/";
 $running = preg_match($running_pattern, $comments) ? true : false;
 // Search the concatenated status output for RUNNING.
 $output_copied = $row["output_copied"];
 $output_copied_display = $output_copied != "" ? "<span title=\"{$output_copied}\">Copied</span>" : "";
 $job_status_class = $status == "QUEUED" ? "job_queued" : ($status == "PENDING" ? "job_pending" : ($status == "STAGING_JOB" ? "job_staging" : ($status == "SUBMITTING" ? "job_submitting" : ($status == "RUNNING" ? "job_running" : ($status == "DELETED" ? "job_deleted" : ($status == "STOPPED" ? "job_stopped" : ($status == "TIMEDOUT" ? "job_timedout" : ($status == "FINISHED" ? "job_finished" : ($status == "FAILED" ? "job_failed" : ($status == "ERROR" ? "job_error" : ""))))))))));
示例#3
0
 public function exitSuccess(ViewFacade $view)
 {
     if (ConfigManager::configHasChanged()) {
         ConfigManager::saveAll();
         $this->logger->info('Config saved".');
     }
     $view->render();
     foreach ($this->interceptors as $interceptor) {
         if (!$interceptor->afterCompletition($this['Symfony\\Request'], $this->components['Symfony\\Response'])) {
             $this->logger->debug('Interceptor afterCompletition() interrupts normal process.');
             exit;
         }
     }
     $execTime = microtime(true) - $this->startupTime;
     $this->logger->debug('Exit success with HTTP code "' . $view->getHttpCode() . '" in ' . $execTime . ' s (' . convert_bytes(memory_get_peak_usage(true)) . ').');
     $this->components['Symfony\\Response']->prepare($this->components['Symfony\\Request']);
     $this->components['Symfony\\Response']->send();
     exit;
 }
function create_file_list($input_dir, $type, $path, $title, $cutoff, $dbpass)
{
    ###### Connect to database ######
    $db = mysql_connect("localhost", "gdbuser", $dbpass);
    if (!$db) {
        echo "Error: Could not connect to database!";
        exit;
    }
    mysql_select_db("Genomes");
    ###### Default Variables ######
    $file_list2 = "";
    $total_size = 0;
    $fileID = "";
    $file_codes = "";
    $abs_size = 0;
    $total_size = 0;
    $multifile_error = "F";
    ###### Create or reproduce file list ######
    if ($type == "list") {
        $file_list = $input_dir;
        //
    } else {
        $file_list = `ls -l --time-style=long-iso {$input_dir}`;
        //
    }
    $list = explode("\n", $file_list);
    # file list array
    $n = 0;
    //valid file count
    $p_flag = "";
    $p_hints = "";
    //permissions problems default -assume none
    ###### Parse each item on file list and add markup for Javascript, styling according to validation ######
    # escape all forward slashes since we are going to put them in an id
    $escaped_path = $type == "dir" ? str_replace("/", "\\/", $input_dir) : "";
    # We only want to assign this if input is directory.
    if (count($list) < 100) {
        #avoid huge directories.
        $v = 0;
        #valid file count
        $iv = 0;
        #invalid file count
        foreach ($list as $item) {
            $pattern = "/\\s+/";
            $replacement = " ";
            $item = preg_replace($pattern, $replacement, $item);
            # collapase spaces
            ###### Select file listings (not directories), parse filename, and run filename validation function   ######
            if (substr($item, 0, 1) == "-") {
                $vals = explode(" ", $item);
                $filename = $vals[count($vals) - 1];
                //e.g. the filename, MyFile_est.fa
                ##### For valid files, parse metadata, create unique filestamp, and start to build a marked-up listing #####
                if (validate_file_type($filename, "") != "") {
                    $n = $n + 1;
                    # To list all files in directory, not just valid ones, move right angle bracket from below to this line.
                    $time = $vals[count($vals) - 2];
                    $year_month_day = $vals[count($vals) - 3];
                    $size = $vals[count($vals) - 4];
                    $filestamp = "{$filename}:{$size}:{$year_month_day}-{$time}";
                    # IMPORTANT: This format MUST be synchronized with FileStamp in /xGDBvm/scripts/xGDB_ValidateFiles.sh
                    ##### Get validation data (if any) from MySQL table based on filestamp, and assign icon color according to result #####
                    $valid = "";
                    $entries = "";
                    $valid_style = "normalfont";
                    $file_info_icon = "information.png";
                    // This icon communicates validation status (by color) and is a click target for opening validation dialog box
                    $validation_time_stamp = "";
                    if ($get_entry = "SELECT Valid, EntryCount, ValidationTimeStamp FROM Datafiles where FileStamp='{$filestamp}'") {
                        $mysql_get_entry = mysql_query($get_entry);
                        while ($result_get_entry = mysql_fetch_array($mysql_get_entry)) {
                            $valid = $result_get_entry[0];
                            # T F or NULL
                            $entries = $result_get_entry[1];
                            # number of entries
                            $validation_time_stamp = $result_get_entry[2];
                            # we use this to find out if there are any multi-file duplication records in Datafiles (see below)
                        }
                    }
                    if ($valid == "T") {
                        $file_info_icon = "information_green.png";
                        $valid_style = "filevalid";
                        $v = $v + 1;
                    } elseif ($valid == "F") {
                        $file_info_icon = "information_red.png";
                        $valid_style = "filenotvalid";
                        $iv = $iv + 1;
                    } else {
                        $file_info_icon = "information.png";
                        $valid_style = "filenoteval";
                    }
                    ##### Build more markup including escaped filepath and validation icons.  #####
                    $filepath = $type == "dir" ? $escaped_path . "\\/" . $filename : "";
                    // We use this as a unique ID tag (with escaped slashes) for opening a Jquery dialog when user clicks icon.
                    $info_icon_styled = $type == "dir" ? "\n\t\t\t\t\t\t      <span id=\"{$filepath}\" class=\"validatefile-button\" title=\"{$filestamp}\">\n\t\t\t\t\t\t         <img class=\"nudge3\" src=\"/XGDB/images/{$file_info_icon}\" />\n\t\t\t\t\t\t      </span>\n\t\t\t\t\t\t      " : "";
                    ##### Get filename code using function that classifies a file type as single-letter code. Concatenate to any previous code string.
                    $file_codes .= get_file_codes($filename);
                    //
                    ##### Get the filename class (e.g. est, cdna, etc) based on the filename suffix. Style this for display. ######
                    $class = $type == "list" ? "darkgrayfont" : "{$valid_style}";
                    # style with colors and image unless it's just a reconstition of the file list.
                    $filename_class = validate_file_type($filename, $class);
                    # returns descriptive file type name
                    $filename_styled = "<span class=\"{$class} italic\">{$filename}</span>";
                    $filename_display = $filename_class . $filename_styled . $info_icon_styled;
                    ##### Start building the file 'list item' core #####
                    $file_list2 .= "<li>";
                    ##### Check for permissions problems in the input directory and append file list string #####
                    $permissions = $vals[0];
                    $p_array = str_split($permissions);
                    //-rw-r--r--
                    if ($p_array[7] != "r") {
                        $p_flag = "<span class='warning'>permissions</span>";
                        // sets flag if any file has permission problem
                        $p_hints = "<span class='tip_style'>To fix permissions problem, on shell: <span class='plaintext'>\$ chmod a+r [myfile]</span>\n\t\t\t\t\t\t\t  <img id='config_data_permissions' title='Click ? for details.' class='help-button nudge1' src='/XGDB/images/help-icon.png' alt='?' />\n\t\t\t\t\t\t\t  </span>";
                        $file_list2 .= "<span class='warning'>[{$permissions}]</span>";
                    }
                    ##### Calculate size in a reasonable numeric range #####
                    $total_size = $total_size + $size;
                    $unit = 0;
                    # 0: bytes, 1: kilobytes, 2: megabytes, 3: gigabytes
                    while ($size > 1024 && $unit < 4) {
                        $size = round($size / 1024, 2);
                        $unit++;
                    }
                    ##### Continue building the file 'list item' core: filename, validation icon, date and time / size / (entries) #####
                    $file_list2 .= "{$filename_display} / {$year_month_day} {$time} / {$size}";
                    ##### If file has been validated, # of entries is available from the MySQL query. Add this here at end of line if available. #####
                    $entries_styled = empty($entries) ? "(not evaluated)" : "<span style=\"color:#00A592\"> \n\t\t\t\t\t\t      {$entries} entries\n\t\t\t\t\t\t   </span>";
                    ##### Determine unit for display and compute absolute size in order to get cumulative total #####
                    if ($unit == 0) {
                        $file_list2 .= " bytes";
                        $abs_size = $size / 1000000;
                    }
                    if ($unit == 1) {
                        $file_list2 .= " KB";
                        $abs_size = $size / 1000;
                    }
                    if ($unit == 2) {
                        $file_list2 .= " MB";
                        $abs_size = $size / 1;
                    }
                    if ($unit == 3) {
                        $file_list2 .= " GB";
                        $abs_size = $size / 0.001;
                    }
                    ##### Finish display with the size units and list end #####
                    $file_list2 .= " / " . $entries_styled;
                    $file_list2 .= "</li>";
                    ##### Finally, check for duplication or other validation problem in multiple files and display as a list item below the regular file listing
                    if ($get_multiple_invalid = "select SeqType, SeqTypeCount from Datafiles where ValidationTimeStamp='{$validation_time_stamp}' and Valid='F' and UserFile='F' and FileStamp LIKE'%{$filestamp}%'") {
                        $mysql_get_multiple_invalid = mysql_query($get_multiple_invalid);
                        while ($result_get_multiple_invalid = mysql_fetch_array($mysql_get_multiple_invalid)) {
                            $seq_type = $result_get_multiple_invalid[0];
                            # e.g. est
                            $seq_type_count = $result_get_multiple_invalid[1];
                            # number of entries
                            $multifile_error = "T";
                            $file_list2 .= "<li style=\"list-style-type:none\"><span class=\"warning\">ERROR: The above <b>{$seq_type}</b> file is one of {$seq_type_count} files that when combined have duplicate IDs or mixed header type</span> </li>";
                        }
                    }
                }
                #					$total_size = $total_size + $abs_size; # moved this
            }
        }
    }
    ##### Calculate the data and validation totals #####
    $total_size_display = convert_bytes($total_size);
    ## Convert to relative size / units
    if ($n < $cutoff) {
        $class = $type == "list" ? "darkgrayfont bold warning" : "alertnotice bold warning";
    } else {
        $class = $type == "list" ? "darkgrayfont" : "checked";
    }
    $ne = $n - ($v + $iv);
    # not evaluated (total minus sum of valid + invalid)
    ##### Build the rest of the list infrastructure (header line, showhide dive and unordered list). Note that $title comes into this function as an argument since text can vary.  #####
    $header_line = "\n\t    <span class=\"largerfont bold\">\n\t      {$path} &nbsp;\n\t    </span>\n\t    <span class=\"heading\">\n\t        Click <img class=\"nudge3\" src=\"/XGDB/images/information_grey.png\" /> to view / validate contents, or use '<span style=\"background-color:#FFB056\">Data Process Options...</span>' to validate all\n\t        <img id='config_file_contents_validation' title='Click ? for details.' class='help-button nudge1' src='/XGDB/images/help-icon.png' alt='?' />\n\t    </span> \n\t    ";
    $valid_count_display = $v > 0 ? "<span class=\"contentsvalid\"> {$v} valid files</span>" : "";
    $invalid_count_display = $iv > 0 ? " <span class=\"contentsnotvalid\"> {$iv} invalid files</span>" : "";
    $noteval_count_display = $ne > 0 ? " <span class=\"contentsnoteval\"> {$ne} files not evaluated</span>" : "";
    $multifile_error_display = $multifile_error == "F" ? "" : "<span class=\"warning\">ERROR: multi-file duplicate IDs or mixed header <img id='config_file_duplicates_error' title='Click ? for details.' class='help-button nudge1' src='/XGDB/images/help-icon.png' alt='?' /> </span>";
    $file_list1 = "\n\t<div class=\"showhide test\">\n\t<p class=\"label\" style=\"cursor:pointer\" title=\"Show file validation\">\n\t\t<span class=\"normalfont\">\n\t\t\t{$title}:\n\t\t</span>\n        <span class=\"normalfont\">\n            {$p_flag}\n        \t{$valid_count_display} {$invalid_count_display} {$noteval_count_display} \n         </span>\n\t \t<span class=\"heading\">\n\t \t\ttotalling {$total_size_display}; {$multifile_error_display} (click for details) </span>\n\t \t</span>\n\t </p>\n\t<div class=\" hidden\" style=\"display: none;\">";
    $file_list1 .= "{$header_line}";
    $file_list1 .= "<ul class=\"bullet1 indent2 create_file_list\">\n\t";
    $file_list3 = "\n\t</ul>{$p_hints}\n\t</div>\n\t</div>";
    ##### Assemble the pieces of the header and list  #####
    $file_list_formatted = $file_list1 . $file_list2 . $file_list3;
    ##### If no data in file list2, don't return anything in this variable  #####
    $file_list_final = $file_list2 == "" ? "" : $file_list_formatted;
    ##### Sort the file codes (see above and get_file_codes) and make them into a concatenated string to represent the file 'fingerprint' for this directory. These will be used to predict output.  #####
    $file_codes = str_split($file_codes, 1);
    sort($file_codes);
    $file_codes = implode('', $file_codes);
    return array($file_list_final, $n, $total_size, $file_list, $file_codes);
    //$total_size in bytes; we return $n in case we want to validate based on valid files
}
示例#5
0
function calculate_scaffolds($input_path, $gsq_proc, $gth_proc)
{
    mysql_select_db("Genomes");
    $size = array();
    $query = "SELECT * from Datafiles where Path='{$input_path}' and SeqType='gdna'";
    $get_query = mysql_query($query);
    $gsq_split_available = $gsq_proc / 8;
    # 8:1 threads (processes)
    $gth_split_available = $gth_proc;
    # 1:1 with threads (processes)
    while ($row = mysql_fetch_array($get_query)) {
        $sequence_count = $row['EntryCount'];
        $total_size = $row['SizeTotal'];
        $size[1] = $row['SizeLargest'];
        $size[2] = $row['Size2'];
        $size[3] = $row['Size3'];
        $size[4] = $row['Size4'];
        $size[5] = $row['Size5'];
        $size[6] = $row['Size6'];
        $size[7] = $row['Size7'];
        $size[8] = $row['Size8'];
        $size[9] = $row['Size9'];
        $size[10] = $row['Size10'];
        $size[11] = $row['Size11'];
        $size[12] = $row['Size12'];
        $size[13] = $row['Size13'];
        $size[14] = $row['Size14'];
        $size[15] = $row['Size15'];
        $size[16] = $row['Size16'];
        $size[17] = $row['Size17'];
        $size[18] = $row['Size18'];
        $size[19] = $row['Size19'];
        $size[20] = $row['Size20'];
    }
    $n = 0;
    $cumulative_size = 0;
    global $large_scaffold_count;
    while ($n < 21 && !isset($large_scaffold_count)) {
        $n = $n + 1;
        $curr_size = $size[$n];
        $cumulative_size = $cumulative_size + $curr_size;
        if ($curr_size == 0) {
            $large_scaffold_count = $n - 1;
            # set because we ran out of scaffolds before there was any drop in size
        } else {
            $m = $n == 1 ? $n : $n - 1;
            #previous scaff
            $prev_size = $size[$m];
            $size_diff = $prev_size - $curr_size;
            $ratio = $size_diff / $curr_size;
            if ($ratio > 10) {
                $large_scaffold_count = $n - 1;
                # set because we ran out of large scaffolds and the remaining ones are much smaller
            }
        }
    }
    $chunks = $n;
    # count of large individual scaffolds plus small 'remaineder' scaffolds catted together
    $remainder_size = $total_size - $cumulative_size;
    # what's left after you subtract out the large scaffolds
    $small_scaffold_count = $sequence_count - $large_scaffold_count;
    $total_size_display = convert_bytes($total_size, 1);
    # convert to MB etc.
    $cumulative_size_display = convert_bytes($cumulative_size, 1);
    # convert
    $remainder_size_display = convert_bytes($remainder_size, 1);
    $gsq_split = $chunks < $gsq_split_available ? $chunks : $gsq_split_available;
    # The actual split is dictated by relative count of chunks and available split .
    $gsq_average = $total_size / $gsq_split;
    $gsq_average_display = convert_bytes($gsq_average, 1);
    # convert
    $gth_split = $chunks < $gth_split_available ? $chunks : $gth_split_available;
    # The actual split is dictated by relative count of chunks and available split .
    $gth_average = $total_size / $gth_split;
    $gth_average_display = convert_bytes($gth_average, 1);
    # convert
    $text1 = $large_scaffold_count == 0 ? "<p class=\"normalfont\" style=\"background-color:white\">Genome Files Not Yet Validated</p>" : "<p class=\"normalfont\" style=\"background-color:white\">This genome has <b>{$large_scaffold_count}</b> large scaffolds totalling <b>{$cumulative_size_display}</b>";
    $text2 = $small_scaffold_count == 0 ? "</p>" : " and <b>{$small_scaffold_count}</b> small scaffolds totaling <b>{$remainder_size_display}</b></p>";
    $scaffold_size_display = $text1 . $text2;
    $gsq_split_display = $large_scaffold_count == 0 ? "" : "<p class=\"normalfont\" style=\"background-color:white\">Genome will be split into <b>{$gsq_split}</b> files averaging <b>{$gsq_average_display}</b> for HPC <br />(<b>{$gsq_proc}</b> processors selected, <b>8</b> threads/file for MPI)</p>";
    $gth_split_display = $large_scaffold_count == 0 ? "" : "<p class=\"normalfont\" style=\"background-color:white\">Genome will be split into <b>{$gth_split}</b> files averaging <b>{$gth_average_display}</b> for HPC <br />(<b>{$gth_proc}</b> processors selected, <b>1</b> thread/file)</p>";
    ## GSQ benchmarking: 3.5 MB/hr per thread
    ## GTH benchmarking: 40 MB/hr per thread
    $gsq_round = $gsq_average / 3400000 > 1 ? 0 : 3;
    // don't show extra sig. fig. if >1 hr
    $gth_round = $gth_average / 40000000 > 1 ? 0 : 3;
    // don't show extra sig. fig. if >1 hr
    $gsq_time = round($gsq_average / 3400000, $gsq_round);
    $gth_time = round($gth_average / 40000000, $gth_round);
    $gsq_time_display = $large_scaffold_count == 0 ? "" : "<p class=\"normalfont\" style=\"background-color:white\">Estimated process time: <b>{$gsq_time}</b> hrs (actual time depends on query dataset size and other factors)</p>";
    $gth_time_display = $large_scaffold_count == 0 ? "" : "<p class=\"normalfont\" style=\"background-color:white\">Estimated process time: <b>{$gth_time}</b> hrs (actual time depends on query dataset size and other factors)</p>";
    return array($large_scaffold_count, $small_scaffold_count, $chunks, $remainder_size, $gsq_split, $gth_split, $scaffold_size_display, $gsq_split_display, $gth_split_display, $gsq_time_display, $gth_time_display);
}
示例#6
0
$track = get_track_id($filepath);
# e.g. "est1"; see conf_functions.inc.php
###### Get totals for this file type among data than may have already been saved (outcome not saved; for display only as the y in 'number x out of y total').  Note we do this whether or not THIS particular file has already been validated.
$seq_type_count_display = "";
$type_count_query = "select count(*) from Datafiles where ValidationTimeStamp='{$validation_time_stamp}' AND SeqType='{$seqtype}'";
// Limits query results to this validation session (if batch)
$check_get_type_count = mysql_query($type_count_query);
$get_type_count_query = mysql_fetch_array($check_get_type_count);
$type_count_total = $get_type_count_query[0];
if ($type_count_total > 1) {
    $seq_type_count_display = "<span style=\"color:darkorange\"> {$seqtypecount} of {$type_count_total}</span>";
}
### Get file size and process for display
$filesize = $exists == "T" ? $filesize : trim(`wc -c < {$filepath_scratch}`);
# file size in bytes
$filesize_display = convert_bytes($filesize);
# conf_functions.inc.php
#     	$filesize_display=preg_replace('/(?<=\d)(?=(\d\d\d)+$)/', ',', $filesize);
### for gff3 output only ###
if ($exists == "F") {
    #		    $pattern="/.+annot\.gff3$/";
    #		    if(preg_match($pattern, $filepath_scratch))
    if ($seqtype == "annot" && $track == "annot") {
        $test = "hello";
        $transcripts = `grep -c -P "\tmRNA\t" {$filepath_scratch}`;
        $entrycount = $transcripts;
        $genes = `grep -c -P "\tgene\t" {$filepath_scratch}`;
        $valid = $transcripts > 0 ? "T" : "F";
        $gfferror = $transcripts > 0 ? "" : "<span class=\"alertnotice\">ERROR: no transcripts could be parsed</span>";
    }
}
示例#7
0
                     // Table is from HEAP-table type
                     echo "<li>{$tablename}: " . $lang['Table_HEAP_info'] . "</li>\n";
                 } else {
                     echo "<li><b>{$tablename}:</b> " . htmlspecialchars($row['Msg_text']) . "</li>\n";
                 }
                 $db->sql_freeresult($result2);
             }
         }
         $db->sql_freeresult($result);
     }
     echo "</ul></font>\n";
     $list_open = FALSE;
     $new_stat = get_table_statistic();
     $reduction_absolute = $old_stat['core']['size'] - $new_stat['core']['size'];
     $reduction_percent = $reduction_absolute / $old_stat['core']['size'] * 100;
     echo "<p class=\"gen\">" . sprintf($lang['Optimization_statistic'], convert_bytes($old_stat['core']['size']), convert_bytes($new_stat['core']['size']), convert_bytes($reduction_absolute), $reduction_percent) . "</b></p>\n";
     lock_db(TRUE);
     break;
 case 'reset_auto_increment':
     // Reset autoincrement values
     echo "<h1>" . $lang['Reset_ai'] . "</h1>\n";
     lock_db();
     echo "<p class=\"gen\"><b>" . $lang['Reset_ai'] . "...</b></p>\n";
     echo "<font class=\"gen\"><ul>\n";
     set_autoincrement(BANLIST_TABLE, 'ban_id', 8);
     set_autoincrement(CATEGORIES_TABLE, 'cat_id', 8);
     set_autoincrement(DISALLOW_TABLE, 'disallow_id', 8);
     set_autoincrement(PRUNE_TABLE, 'prune_id', 8);
     set_autoincrement(GROUPS_TABLE, 'group_id', 8, FALSE);
     set_autoincrement(POSTS_TABLE, 'post_id', 8);
     set_autoincrement(PRIVMSGS_TABLE, 'privmsgs_id', 8);
示例#8
0
function sys_memory()
{
    $proc_meminfo = file("/proc/meminfo");
    // gather system memory information
    for ($i = 0; $proc_meminfo[$i] != NULL; $i++) {
        if (ereg("Mem:", $proc_meminfo[$i])) {
            $clean = ereg_replace(' +', ' ', $proc_meminfo[$i]);
            // compact whitespace
            $mem = explode(" ", $clean);
        }
        if (ereg("Swap:", $proc_meminfo[$i])) {
            $clean = ereg_replace(' +', ' ', $proc_meminfo[$i]);
            // compact whitespace
            $swap = explode(" ", $clean);
        }
    }
    // create the data structure
    // 1 = total, 2 = used, 3 = free, 4 = shared, 5 = buffers, 6 = cached
    $memory["mem_total"] = convert_bytes($mem[1]);
    $memory["mem_used"] = convert_bytes($mem[2] - $mem[5] - $mem[6]);
    $memory["mem_free"] = convert_bytes($mem[1] - ($mem[2] - $mem[5] - $mem[6]));
    $memory["mem_used_p"] = round(($mem[2] - $mem[5] - $mem[6]) / $mem[1] * 100, 2);
    $memory["mem_free_p"] = round(($mem[1] - ($mem[2] - $mem[5] - $mem[6])) / $mem[1] * 100, 2);
    $memory["swap_total"] = convert_bytes($swap[1]);
    $memory["swap_used"] = convert_bytes($swap[2]);
    $memory["swap_free"] = convert_bytes($swap[3]);
    $memory["swap_used_p"] = round($swap[2] / $swap[1] * 100, 2);
    $memory["swap_free_p"] = round($swap[3] / $swap[1] * 100, 2);
    // return the data structure
    return $memory;
}
                     // Table is from HEAP-table type
                     echo "<li>{$tablename}: " . $lang['Table_HEAP_info'] . "</li>\n";
                 } else {
                     echo "<li><b>{$tablename}:</b> " . htmlspecialchars($row['Msg_text']) . "</li>\n";
                 }
                 $db->sql_freeresult($result2);
             }
         }
         $db->sql_freeresult($result);
     }
     echo "</ul></div>\n";
     $list_open = false;
     $new_stat = get_table_statistic();
     $reduction_absolute = $old_stat['core']['size'] - $new_stat['core']['size'];
     $reduction_percent = $reduction_absolute / $old_stat['core']['size'] * 100;
     echo '<p class="gen">' . sprintf($lang['Optimization_statistic'], convert_bytes($old_stat['core']['size']), convert_bytes($new_stat['core']['size']), convert_bytes($reduction_absolute), $reduction_percent) . '</b></p>' . "\n";
     lock_db(true);
     break;
 case 'reset_auto_increment':
     // Reset autoincrement values
     echo '<h1>' . $lang['Reset_ai'] . '</h1>' . "\n";
     lock_db();
     echo '<p class="gen"><b>' . $lang['Reset_ai'] . "...</b></p>\n";
     echo "<div class=\"post-text\"><ul>\n";
     set_autoincrement(BANLIST_TABLE, 'ban_id', 8);
     set_autoincrement(DISALLOW_TABLE, 'disallow_id', 8);
     set_autoincrement(PRUNE_TABLE, 'prune_id', 8);
     set_autoincrement(GROUPS_TABLE, 'group_id', 8, false);
     set_autoincrement(POSTS_TABLE, 'post_id', 8);
     set_autoincrement(PRIVMSGS_TABLE, 'privmsgs_id', 8);
     set_autoincrement(RANKS_TABLE, 'rank_id', 5);