Documentation TYPO3 par Ameos

server_databases.php

00001 <?php
00002 /* $Id: server_databases.php,v 2.4 2003/11/26 22:52:24 rabus Exp $ */
00003 // vim: expandtab sw=4 ts=4 sts=4:
00004 
00005 
00009 require_once('./libraries/grab_globals.lib.php');
00010 
00011 
00015 $js_to_run = 'functions.js';
00016 require('./server_common.inc.php');
00017 
00018 ?>
00019 <script type="text/javascript" language="javascript1.2">
00020 <!--
00021 function reload_window(db) {
00022     if (typeof(window.parent) != 'undefined'
00023         && typeof(window.parent.frames['nav']) != 'undefined') {
00024         window.parent.frames['nav'].location.replace('./left.php?<?php echo PMA_generate_common_url('','','&');?>&db=' + db + '&hash=' + <?php echo (($cfg['QueryFrame'] && $cfg['QueryFrameJS']) ? 'window.parent.frames[\'queryframe\'].document.hashform.hash.value' : "'" . md5($cfg['PmaAbsoluteUri']) . "'"); ?>);
00025     }
00026 }
00027 //-->
00028 </script>
00029 
00030 <?php
00031 
00046 function PMA_dbCmp($a, $b)
00047 {
00048     global $sort_by, $sort_order;
00049     if ($sort_by == 'db_name') {
00050         return ($sort_order == 'asc' ? 1 : -1) * strcasecmp($a['db_name'], $b['db_name']);
00051     } else if ($a[$sort_by] == $b[$sort_by]) {
00052         return strcasecmp($a['db_name'], $b['db_name']);
00053     } else {
00054         return ($sort_order == 'asc' ? 1 : -1) * ((int)$a[$sort_by] > (int)$b[$sort_by] ? 1 : -1);
00055     }
00056 } // end of the 'PMA_dbCmp()' function
00057 
00058 
00062 if ($server > 0 && empty($dblist)) {
00063     PMA_availableDatabases();
00064 }
00065 
00066 
00070 if ((!empty($drop_selected_dbs) || isset($query_type)) && ($is_superuser || $cfg['AllowUserDropDatabase'])) {
00071     if (empty($selected_db) && ! (isset($query_type) && !empty($selected))) {
00072         $message = $strNoDatabasesSelected;
00073     } else {
00074         $action = 'server_databases.php';
00075         $submit_mult = 'drop_db' ;
00076         $err_url = 'server_databases.php?' . PMA_generate_common_url();
00077         require('./mult_submits.inc.php');
00078         $message = sprintf($strDatabasesDropped, count($selected));
00079         // we need to reload the database list now.
00080         PMA_availableDatabases();
00081         $reload = 1;
00082     }
00083 }
00084 
00085 
00089 require('./server_links.inc.php');
00090 
00091 
00095 echo '<h2>' . "\n"
00096    . '    ' . (empty($dbstats) ? $strDatabases : $strDatabasesStats) . "\n"
00097    . '</h2>' . "\n";
00098 
00099 
00103 if (!empty($dbstats) && !$is_superuser) {
00104     echo $strNoPrivileges . "\n";
00105     require_once('./footer.inc.php');
00106 }
00107 
00108 
00112 $statistics = array();
00113 foreach($dblist AS $current_db) {
00114     $tmp_array = array(
00115         'db_name' => $current_db,
00116         'tbl_cnt' => 0,
00117         'data_sz' => 0,
00118         'idx_sz' => 0,
00119         'tot_sz' => 0
00120     );
00121     if (!empty($dbstats)) {
00122         $res = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($current_db) . ';', $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), 'SHOW TABLE STATUS FROM ' . PMA_backquote($current_db) . ';');
00123         while ($row = PMA_mysql_fetch_array($res, MYSQL_ASSOC)) {
00124             $tmp_array['tbl_cnt']++;
00125             $tmp_array['data_sz'] += $row['Data_length'];
00126             $tmp_array['idx_sz'] += $row['Index_length'];
00127         }
00128     }
00129     $tmp_array['tot_sz'] = $tmp_array['data_sz'] + $tmp_array['idx_sz'];
00130     $statistics[] = $tmp_array;
00131 }
00132 
00133 // avoids 'undefined index' errors
00134 if (empty($sort_by)) {
00135     $sort_by = 'db_name';
00136 }
00137 if (empty($sort_order)) {
00138     if ($sort_by == 'db_name') {
00139         $sort_order = 'asc';
00140     } else {
00141         $sort_order = 'desc';
00142     }
00143 }
00144 
00145 // sorts the array
00146 usort($statistics, 'PMA_dbCmp');
00147 
00148 
00152 if (count($statistics) > 0) {
00153     echo '<form action="./server_databases.php" method="post" name="dbStatsForm">' . "\n"
00154        . PMA_generate_common_hidden_inputs('', '', 1)
00155        . '    <input type="hidden" name="dbstats" value="' . (empty($dbstats) ? '0' : '1') . '" />' . "\n"
00156        . '    <input type="hidden" name="sort_by" value="' . $sort_by . '" />' . "\n"
00157        . '    <input type="hidden" name="sort_order" value="' . $sort_order . '" />' . "\n"
00158        . '    <table border="0">' . "\n"
00159        . '        <tr>' . "\n"
00160        . ($is_superuser || $cfg['AllowUserDropDatabase'] ? '            <th>&nbsp;</th>' . "\n" : '')
00161        . '            <th>' . "\n"
00162        . '                &nbsp;';
00163     if (empty($dbstats)) {
00164         echo $strDatabase . "\n"
00165            . '                <img src="./images/asc_order.png" border="0" width="7" height="7"  alt="' . $strAscending . '" />' . "\n"
00166            . '                &nbsp;' . "\n"
00167            . '            </th>' . "\n";
00168     } else {
00169         echo "\n"
00170            . '                <a href="./server_databases.php?' . $url_query . '&amp;dbstats=1&amp;sort_by=db_name&amp;sort_order=' . (($sort_by == 'db_name' && $sort_order == 'asc') ? 'desc' : 'asc') . '">' . "\n"
00171            . '                    ' . $strDatabase . "\n"
00172            . ($sort_by == 'db_name' ? '                    <img src="./images/' . $sort_order . '_order.png" border="0" width="7" height="7"  alt="' . ($sort_order == 'asc' ? $strAscending : $strDescending) . '" />' . "\n" : '')
00173            . '                </a>' . "\n"
00174            . '                &nbsp;' . "\n"
00175            . '            </th>' . "\n"
00176            . '            <th>' . "\n"
00177            . '                &nbsp;' . "\n"
00178            . '                <a href="./server_databases.php?' . $url_query . '&amp;dbstats=1&amp;sort_by=tbl_cnt&amp;sort_order=' . (($sort_by == 'tbl_cnt' && $sort_order == 'desc') ? 'asc' : 'desc') . '">' . "\n"
00179            . '                    ' . $strNumTables . "\n"
00180            . ($sort_by == 'tbl_cnt' ? '                    <img src="./images/' . $sort_order . '_order.png" border="0" width="7" height="7"  alt="' . ($sort_order == 'asc' ? $strAscending : $strDescending) . '" />' . "\n" : '')
00181            . '                </a>' . "\n"
00182            . '                &nbsp;' . "\n"
00183            . '            </th>' . "\n"
00184            . '            <th colspan="2">' . "\n"
00185            . '                &nbsp;' . "\n"
00186            . '                <a href="./server_databases.php?' . $url_query . '&amp;dbstats=1&amp;sort_by=data_sz&amp;sort_order=' . (($sort_by == 'data_sz' && $sort_order == 'desc') ? 'asc' : 'desc') . '">' . "\n"
00187            . '                    ' . $strData . "\n"
00188            . ($sort_by == 'data_sz' ? '                    <img src="./images/' . $sort_order . '_order.png" border="0" width="7" height="7"  alt="' . ($sort_order == 'asc' ? $strAscending : $strDescending) . '" />' . "\n" : '')
00189            . '                </a>' . "\n"
00190            . '                &nbsp;' . "\n"
00191            . '            </th>' . "\n"
00192            . '            <th colspan="2">' . "\n"
00193            . '                &nbsp;' . "\n"
00194            . '                <a href="./server_databases.php?' . $url_query . '&amp;dbstats=1&amp;sort_by=idx_sz&amp;sort_order=' . (($sort_by == 'idx_sz' && $sort_order == 'desc') ? 'asc' : 'desc') . '">' . "\n"
00195            . '                    ' . $strIndexes . "\n"
00196            . ($sort_by == 'idx_sz' ? '                    <img src="./images/' . $sort_order . '_order.png" border="0" width="7" height="7"  alt="' . ($sort_order == 'asc' ? $strAscending : $strDescending) . '" />' . "\n" : '')
00197            . '                </a>' . "\n"
00198            . '                &nbsp;' . "\n"
00199            . '            </th>' . "\n"
00200            . '            <th colspan="2">' . "\n"
00201            . '                &nbsp;' . "\n"
00202            . '                <a href="./server_databases.php?' . $url_query . '&amp;dbstats=1&amp;sort_by=tot_sz&amp;sort_order=' . (($sort_by == 'tot_sz' && $sort_order == 'desc') ? 'asc' : 'desc') . '">' . "\n"
00203            . '                    ' . $strTotalUC . "\n"
00204            . ($sort_by == 'tot_sz' ? '                    <img src="./images/' . $sort_order . '_order.png" border="0" width="7" height="7"  alt="' . ($sort_order == 'asc' ? $strAscending : $strDescending) . '" />' . "\n" : '')
00205            . '                </a>' . "\n"
00206            . '                &nbsp;' . "\n"
00207            . '            </th>' . "\n";
00208     }
00209     if ($is_superuser) {
00210         echo '            <th>' . "\n"
00211            . '                &nbsp;' . $strAction . '&nbsp;' . "\n"
00212            . '            </th>' . "\n";
00213     }
00214     echo '        </tr>' . "\n";
00215     $useBgcolorOne = TRUE;
00216     $total_calc = array(
00217         'db_cnt' => 0,
00218         'tbl_cnt' => 0,
00219         'data_sz' => 0,
00220         'idx_sz' => 0,
00221         'tot_sz' => 0
00222     );
00223     foreach ($statistics as $current) {
00224         list($data_size, $data_unit) = PMA_formatByteDown($current['data_sz'], 3, 1);
00225         list($idx_size, $idx_unit)   = PMA_formatByteDown($current['idx_sz'], 3, 1);
00226         list($tot_size, $tot_unit)   = PMA_formatByteDown($current['tot_sz'], 3, 1);
00227         $total_calc['db_cnt']++;
00228         $total_calc['tbl_cnt'] += $current['tbl_cnt'];
00229         $total_calc['data_sz'] += $current['data_sz'];
00230         $total_calc['idx_sz']  += $current['idx_sz'];
00231         $total_calc['tot_sz']  += $current['tot_sz'];
00232         echo '        <tr>' . "\n";
00233         if ($is_superuser || $cfg['AllowUserDropDatabase']) {
00234             echo '            <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n"
00235                . '                <input type="checkbox" name="selected_db[]" title="' . htmlspecialchars($current['db_name']) . '" value="' . htmlspecialchars($current['db_name']) . '" ' . (empty($checkall) ? '' : 'checked="checked" ') . '/>' . "\n"
00236                . '            </td>' . "\n";
00237         }
00238         echo '            <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n"
00239            . '                <a onclick="reload_window(\'' . urlencode($current['db_name']) . '\'); return true;" href="' . $cfg['DefaultTabDatabase'] . '?' . $url_query . '&amp;db=' . urlencode($current['db_name']) . '" title="' . sprintf($strJumpToDB, htmlspecialchars($current['db_name'])) . '">' . "\n"
00240            . '                    ' . htmlspecialchars($current['db_name']) . "\n"
00241            . '                </a>' . "\n"
00242            . '            </td>' . "\n";
00243         if (!empty($dbstats)) {
00244             echo '            <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '" align="right">' . "\n"
00245                . '                ' . $current['tbl_cnt'] . "\n"
00246                . '            </td>' . "\n"
00247                . '            <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '" align="right">' . "\n"
00248                . '                ' . $data_size . "\n"
00249                . '            </td>' . "\n"
00250                . '            <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n"
00251                . '                ' . $data_unit . "\n"
00252                . '            </td>' . "\n"
00253                . '            <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '" align="right">' . "\n"
00254                . '                ' . $idx_size . "\n"
00255                . '            </td>' . "\n"
00256                . '            <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n"
00257                . '                ' . $idx_unit . "\n"
00258                . '            </td>' . "\n"
00259                . '            <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '" align="right">' . "\n"
00260                . '                <b>' . "\n"
00261                . '                    ' . $tot_size . "\n"
00262                . '                </b>' . "\n"
00263                . '            </td>' . "\n"
00264                . '            <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n"
00265                . '                <b>' . "\n"
00266                . '                    ' . $tot_unit . "\n"
00267                . '                </b>' . "\n"
00268                . '            </td>' . "\n";
00269         }
00270         if ($is_superuser) {
00271             echo '            <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n"
00272                . '                <a onclick="reload_window(\'' . urlencode($current['db_name']) . '\'); return true;" href="./server_privileges.php?' . $url_query . '&amp;checkprivs=' . urlencode($current['db_name']) . '" title="' . sprintf($strCheckPrivsLong, htmlspecialchars($current['db_name'])) . '">'. "\n"
00273                . '                    ' . $strCheckPrivs . "\n"
00274                . '                </a>' . "\n"
00275                . '            </td>' . "\n";
00276         }
00277         echo '        </tr>' . "\n";
00278         $useBgcolorOne = !$useBgcolorOne;
00279     } // end while
00280     if (!empty($dbstats)) {
00281         list($data_size, $data_unit) = PMA_formatByteDown($total_calc['data_sz'], 3, 1);
00282         list($idx_size, $idx_unit)   = PMA_formatByteDown($total_calc['idx_sz'], 3, 1);
00283         list($tot_size, $tot_unit)   = PMA_formatByteDown($total_calc['tot_sz'], 3, 1);
00284         echo '        <tr>' . "\n"
00285            . '            <th>&nbsp;</th>' . "\n"
00286            . '            <th>' . "\n"
00287            . '                &nbsp;' . $strTotalUC . ':&nbsp;' . $total_calc['db_cnt'] . '&nbsp;' . "\n"
00288            . '            </th>' . "\n"
00289            . '            <th align="right">' . "\n"
00290            . '                &nbsp;' . $total_calc['tbl_cnt'] . '&nbsp;' . "\n"
00291            . '            </th>' . "\n"
00292            . '            <th align="right">' . "\n"
00293            . '                &nbsp;' . $data_size . "\n"
00294            . '            </th>' . "\n"
00295            . '            <th align="left">' . "\n"
00296            . '                ' . $data_unit . '&nbsp;' . "\n"
00297            . '            </th>' . "\n"
00298            . '            <th align="right">' . "\n"
00299            . '                &nbsp;' . $idx_size . "\n"
00300            . '            </th>' . "\n"
00301            . '            <th align="left">' . "\n"
00302            . '                ' . $idx_unit . '&nbsp;' . "\n"
00303            . '            </th>' . "\n"
00304            . '            <th align="right">' . "\n"
00305            . '                &nbsp;' . $tot_size . "\n"
00306            . '            </th>' . "\n"
00307            . '            <th align="left">' . "\n"
00308            . '                ' . $tot_unit . '&nbsp;' . "\n"
00309            . '            </th>' . "\n"
00310            . '            <th>&nbsp;</th>' . "\n"
00311            . '        </tr>' . "\n";
00312     }
00313     if ($is_superuser || $cfg['AllowUserDropDatabase']) {
00314         $common_url_query = PMA_generate_common_url() . '&amp;sort_by=' . $sort_by . '&amp;sort_order=' . $sort_order . '&amp;dbstats=' . (empty($dbstats) ? '10' : '3');
00315         echo '    <tr>' . "\n"
00316            . '        <td colspan="' . (empty($dbstats) ? '10' : '3') . '">' . "\n"
00317            . '            <img src="./images/arrow_' . $text_dir . '.gif" border="0" width="38" height="22" alt="' . $strWithChecked . '" />' . "\n"
00318            . '            <a href="./server_databases.php?' . $common_url_query . '&amp;checkall=1" onclick="setCheckboxes(\'dbStatsForm\', true); return false;">' . "\n"
00319            . '                ' . $strCheckAll
00320            . '            </a>' . "\n"
00321            . '            &nbsp;/&nbsp;' . "\n"
00322            . '            <a href="./server_databases.php?' . $common_url_query . '" onclick="setCheckboxes(\'dbStatsForm\', false); return false;">' . "\n"
00323            . '                ' . $strUncheckAll
00324            . '            </a>' . "\n"
00325            . '        </td>' . "\n"
00326            . '    </tr>' . "\n";
00327     }
00328     echo '    </table>' . "\n";
00329     unset($data_size);
00330     unset($data_unit);
00331     unset($idx_size);
00332     unset($idx_unit);
00333     unset($tot_size);
00334     unset($tot_unit);
00335     if ($is_superuser || $cfg['AllowUserDropDatabase']) {
00336         echo '    <ul>' . "\n";
00337     }
00338     if ($is_superuser && empty($dbstats)) {
00339         echo '        <li>' . "\n"
00340            . '            <b>' . "\n"
00341            . '                <a href="./server_databases.php?' . $url_query . '&amp;dbstats=1" title="' . $strDatabasesStatsEnable . '">' . "\n"
00342            . '                    ' . $strDatabasesStatsEnable . "\n"
00343            . '                </a>' . "\n"
00344            . '            </b>' . "\n"
00345            . '            <br />' . "\n"
00346            . '            ' . $strDatabasesStatsHeavyTraffic . "\n"
00347            . '        </li><br /><br />' . "\n";
00348     } else if ($is_superuser && !empty($dbstats)) {
00349         echo '        <li>' . "\n"
00350            . '            <b>' . "\n"
00351            . '                <a href="./server_databases.php?' . $url_query . '" title="' . $strDatabasesStatsDisable . '">'. "\n"
00352            . '                    ' . $strDatabasesStatsDisable . "\n"
00353            . '                </a>' . "\n"
00354            . '            </b>' . "\n"
00355            . '        </li><br /><br />' . "\n";
00356     }
00357     if ($is_superuser || $cfg['AllowUserDropDatabase']) {
00358         echo '        <li>' . "\n"
00359            . '            <b>' . "\n"
00360            . '                ' . $strDropSelectedDatabases . "\n"
00361            . '            </b><br />' . "\n"
00362            . '            <input type="submit" name="drop_selected_dbs" value="' . $strGo . '" />' . "\n"
00363            . '        </li>' . "\n"
00364            . '    </ul>' . "\n";
00365     }
00366     echo '</form>' . "\n";
00367 } else {
00368     echo $strNoDatabases . "\n";
00369 }
00370 
00371 
00375 require_once('./footer.inc.php');
00376 
00377 ?>


Généré par TYPO3 Ameos avec  doxygen 1.4.6