/** * Prints details about the current Git commit revision */ function PMA_printGitRevision() { if (!$GLOBALS['PMA_Config']->get('PMA_VERSION_GIT')) { PMA_ajaxResponse('', false); } // load revision data from repo $GLOBALS['PMA_Config']->checkGitRevision(); // if using a remote commit fast-forwarded, link to Github $commit_hash = substr($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITHASH'), 0, 7); $commit_hash = '<strong title="' . htmlspecialchars($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_MESSAGE')) . '">' . $commit_hash . '</strong>'; if ($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_ISREMOTECOMMIT')) { $commit_hash = '<a href="' . PMA_linkURL('https://github.com/phpmyadmin/phpmyadmin/commit/' . $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITHASH')) . '" target="_blank">' . $commit_hash . '</a>'; } $branch = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_BRANCH'); if ($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_ISREMOTEBRANCH')) { $branch = '<a href="' . PMA_linkURL('https://github.com/phpmyadmin/phpmyadmin/tree/' . $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_BRANCH')) . '" target="_blank">' . $branch . '</a>'; } if ($branch !== false) { $branch = sprintf(__('%1$s from %2$s branch'), $commit_hash, $branch); } else { $branch = $commit_hash . ' (' . __('no branch') . ')'; } ob_start(); $committer = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITTER'); $author = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_AUTHOR'); PMA_printListItem(__('Git revision') . ': ' . $branch . ',<br /> ' . sprintf(__('committed on %1$s by %2$s'), PMA_localisedDate(strtotime($committer['date'])), '<a href="' . PMA_linkURL('mailto:' . $committer['email']) . '">' . htmlspecialchars($committer['name']) . '</a>') . ($author != $committer ? ', <br />' . sprintf(__('authored on %1$s by %2$s'), PMA_localisedDate(strtotime($author['date'])), '<a href="' . PMA_linkURL('mailto:' . $author['email']) . '">' . htmlspecialchars($author['name']) . '</a>') : ''), 'li_pma_version_git', null, null, null); $item = ob_get_contents(); ob_end_clean(); PMA_ajaxResponse($item, true); }
/** * Outputs export header * * @return bool Whether it suceeded * * @access public */ function PMA_exportHeader() { global $crlf; global $cfg; if ($GLOBALS['output_charset_conversion']) { $charset = $GLOBALS['charset_of_file']; } else { $charset = $GLOBALS['charset']; } $head = '<?xml version="1.0" encoding="' . $charset . '" ?>' . $crlf . '<!--' . $crlf . '-' . $crlf . '- phpMyAdmin XML Dump' . $crlf . '- version ' . PMA_VERSION . $crlf . '- http://www.phpmyadmin.net' . $crlf . '-' . $crlf . '- ' . $GLOBALS['strHost'] . ': ' . $cfg['Server']['host']; if (!empty($cfg['Server']['port'])) { $head .= ':' . $cfg['Server']['port']; } $head .= $crlf . '- ' . $GLOBALS['strGenTime'] . ': ' . PMA_localisedDate() . $crlf . '- ' . $GLOBALS['strServerVersion'] . ': ' . substr(PMA_MYSQL_INT_VERSION, 0, 1) . '.' . (int) substr(PMA_MYSQL_INT_VERSION, 1, 2) . '.' . (int) substr(PMA_MYSQL_INT_VERSION, 3) . $crlf . '- ' . $GLOBALS['strPHPVersion'] . ': ' . phpversion() . $crlf . '-->' . $crlf . $crlf; return PMA_exportOutputHandler($head); }
/** * fills given tooltip arrays * * @uses $cfg['ShowTooltipAliasTB'] * @uses $GLOBALS['strStatCreateTime'] * @uses PMA_localisedDate() * @uses strtotime() * @param array $tooltip_truename tooltip data * @param array $tooltip_aliasname tooltip data * @param array $table tabledata */ function PMA_fillTooltip(&$tooltip_truename, &$tooltip_aliasname, $table) { if (empty($table['Comment'])) { $table['Comment'] = $table['Name']; } else { // why? $table['Comment'] .= ' '; } if ($GLOBALS['cfg']['ShowTooltipAliasTB'] && $GLOBALS['cfg']['ShowTooltipAliasTB'] != 'nested') { $tooltip_truename[$table['Name']] = $table['Comment']; $tooltip_aliasname[$table['Name']] = $table['Name']; } else { $tooltip_truename[$table['Name']] = $table['Name']; $tooltip_aliasname[$table['Name']] = $table['Comment']; } if (isset($table['Create_time']) && !empty($table['Create_time'])) { $tooltip_aliasname[$table['Name']] .= ', ' . $GLOBALS['strStatCreateTime'] . ': ' . PMA_localisedDate(strtotime($table['Create_time'])); } if (!empty($table['Update_time'])) { $tooltip_aliasname[$table['Name']] .= ', ' . $GLOBALS['strStatUpdateTime'] . ': ' . PMA_localisedDate(strtotime($table['Update_time'])); } if (!empty($table['Check_time'])) { $tooltip_aliasname[$table['Name']] .= ', ' . $GLOBALS['strStatCheckTime'] . ': ' . PMA_localisedDate(strtotime($table['Check_time'])); } }
/** * Outputs export header * * @return bool Whether it suceeded * * @access public */ function PMA_exportHeader() { global $crlf; global $cfg; $head = '% phpMyAdmin LaTeX Dump' . $crlf . '% version ' . PMA_VERSION . $crlf . '% http://www.phpmyadmin.net' . $crlf . '%' . $crlf . '% ' . $GLOBALS['strHost'] . ': ' . $cfg['Server']['host']; if (!empty($cfg['Server']['port'])) { $head .= ':' . $cfg['Server']['port']; } $head .= $crlf . '% ' . $GLOBALS['strGenTime'] . ': ' . PMA_localisedDate() . $crlf . '% ' . $GLOBALS['strServerVersion'] . ': ' . substr(PMA_MYSQL_INT_VERSION, 0, 1) . '.' . (int) substr(PMA_MYSQL_INT_VERSION, 1, 2) . '.' . (int) substr(PMA_MYSQL_INT_VERSION, 3) . $crlf . '% ' . $GLOBALS['strPHPVersion'] . ': ' . phpversion() . $crlf; return PMA_exportOutputHandler($head); }
/** * This function must be named "Footer" to work with the TCPDF library */ function Footer() { // Check if footer for this page already exists if (!isset($this->footerset[$this->page])) { $this->SetY(-15); $this->SetFont(PMA_PDF_FONT, '', 14); $this->Cell(0, 6, __('Page number:') . ' ' . $this->getAliasNumPage() . '/' . $this->getAliasNbPages(), 'T', 0, 'C'); $this->Cell(0, 6, PMA_localisedDate(), 0, 1, 'R'); $this->SetY(20); // set footerset $this->footerset[$this->page] = 1; } }
function fillTooltip(&$tooltip_truename, &$tooltip_aliasname, &$tmp) { $tooltip_truename[$tmp['Name']] = $GLOBALS['cfg']['ShowTooltipAliasTB'] && $GLOBALS['cfg']['ShowTooltipAliasTB'] != 'nested' ? !empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : $tmp['Name'] : $tmp['Name']; $tooltip_aliasname[$tmp['Name']] = $GLOBALS['cfg']['ShowTooltipAliasTB'] && $GLOBALS['cfg']['ShowTooltipAliasTB'] != 'nested' ? $tmp['Name'] : (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : $tmp['Name']); if (isset($tmp['Create_time']) && !empty($tmp['Create_time'])) { $tooltip_aliasname[$tmp['Name']] .= ', ' . $GLOBALS['strStatCreateTime'] . ': ' . PMA_localisedDate(strtotime($tmp['Create_time'])); } if (isset($tmp['Update_time']) && !empty($tmp['Update_time'])) { $tooltip_aliasname[$tmp['Name']] .= ', ' . $GLOBALS['strStatUpdateTime'] . ': ' . PMA_localisedDate(strtotime($tmp['Update_time'])); } if (isset($tmp['Check_time']) && !empty($tmp['Check_time'])) { $tooltip_aliasname[$tmp['Name']] .= ', ' . $GLOBALS['strStatCheckTime'] . ': ' . PMA_localisedDate(strtotime($tmp['Check_time'])); } return true; }
function PMA_transformation_text_plain__dateformat($buffer, $options = array(), $meta = '') { // possibly use a global transform and feed it with special options: // include('./libraries/transformations/global.inc.php'); // further operations on $buffer using the $options[] array. if (!isset($options[0]) || $options[0] == '') { $options[0] = 0; } if (!isset($options[1]) || $options[1] == '') { $options[1] = $GLOBALS['datefmt']; } $timestamp = -1; // Detect TIMESTAMP(6 | 8 | 10 | 12 | 14), (2 | 4) not supported here. if (preg_match('/^(\\d{2}){3,7}$/', $buffer)) { if (strlen($buffer) == 14 || strlen($buffer) == 8) { $offset = 4; } else { $offset = 2; } $d = array(); $d['year'] = substr($buffer, 0, $offset); $d['month'] = substr($buffer, $offset, 2); $d['day'] = substr($buffer, $offset + 2, 2); $d['hour'] = substr($buffer, $offset + 4, 2); $d['minute'] = substr($buffer, $offset + 6, 2); $d['second'] = substr($buffer, $offset + 8, 2); if (checkdate($d['month'], $d['day'], $d['year'])) { $timestamp = mktime($d['hour'], $d['minute'], $d['second'], $d['month'], $d['day'], $d['year']); } // If all fails, assume one of the dozens of valid strtime() syntaxes (http://www.gnu.org/manual/tar-1.12/html_chapter/tar_7.html) } else { $timestamp = strtotime($buffer); } // If all above failed, maybe it's a Unix timestamp already? if ($timestamp < 0 && preg_match('/^[1-9]\\d{1,9}$/', $buffer)) { $timestamp = $buffer; } // Reformat a valid timestamp if ($timestamp >= 0) { $timestamp -= $options[0] * 60 * 60; $source = $buffer; $buffer = '<dfn onclick="alert(\'' . $source . '\');" title="' . $source . '">' . PMA_localisedDate($timestamp, $options[1]) . '</dfn>'; } return $buffer; }
/** * fills given tooltip arrays * * @param array $tooltip_truename tooltip data * @param array $tooltip_aliasname tooltip data * @param array $table tabledata */ function PMA_fillTooltip(&$tooltip_truename, &$tooltip_aliasname, $table) { if (strstr($table['Comment'], '; InnoDB free') === false) { if (!strstr($table['Comment'], 'InnoDB free') === false) { // here we have just InnoDB generated part $table['Comment'] = ''; } } else { // remove InnoDB comment from end, just the minimal part (*? is non greedy) $table['Comment'] = preg_replace('@; InnoDB free:.*?$@', '', $table['Comment']); } // views have VIEW as comment so it's not a real comment put by a user if ('VIEW' == $table['Comment']) { $table['Comment'] = ''; } if (empty($table['Comment'])) { $table['Comment'] = $table['Name']; } else { // why? $table['Comment'] .= ' '; } if ($GLOBALS['cfg']['ShowTooltipAliasTB'] && $GLOBALS['cfg']['ShowTooltipAliasTB'] !== 'nested') { $tooltip_truename[$table['Name']] = $table['Comment']; $tooltip_aliasname[$table['Name']] = $table['Name']; } else { $tooltip_truename[$table['Name']] = $table['Name']; $tooltip_aliasname[$table['Name']] = $table['Comment']; } if (isset($table['Create_time']) && !empty($table['Create_time'])) { $tooltip_aliasname[$table['Name']] .= ', ' . __('Creation') . ': ' . PMA_localisedDate(strtotime($table['Create_time'])); } if (!empty($table['Update_time'])) { $tooltip_aliasname[$table['Name']] .= ', ' . __('Last update') . ': ' . PMA_localisedDate(strtotime($table['Update_time'])); } if (!empty($table['Check_time'])) { $tooltip_aliasname[$table['Name']] .= ', ' . __('Last check') . ': ' . PMA_localisedDate(strtotime($table['Check_time'])); } }
/** * */ function PMA_transformation_text_plain__dateformat($buffer, $options = array(), $meta = '') { // possibly use a global transform and feed it with special options: // include './libraries/transformations/global.inc.php'; // further operations on $buffer using the $options[] array. if (empty($options[0])) { $options[0] = 0; } if (empty($options[2])) { $options[2] = 'local'; } else { $options[2] = strtolower($options[2]); } if (empty($options[1])) { if ($options[2] == 'local') { $options[1] = __('%B %d, %Y at %I:%M %p'); } else { $options[1] = 'Y-m-d H:i:s'; } } $timestamp = -1; // INT columns will be treated as UNIX timestamps // and need to be detected before the verification for // MySQL TIMESTAMP if ($meta->type == 'int') { $timestamp = $buffer; // Detect TIMESTAMP(6 | 8 | 10 | 12 | 14) // TIMESTAMP (2 | 4) not supported here. // (Note: prior to MySQL 4.1, TIMESTAMP has a display size, for example // TIMESTAMP(8) means YYYYMMDD) } else { if (preg_match('/^(\\d{2}){3,7}$/', $buffer)) { if (strlen($buffer) == 14 || strlen($buffer) == 8) { $offset = 4; } else { $offset = 2; } $d = array(); $d['year'] = substr($buffer, 0, $offset); $d['month'] = substr($buffer, $offset, 2); $d['day'] = substr($buffer, $offset + 2, 2); $d['hour'] = substr($buffer, $offset + 4, 2); $d['minute'] = substr($buffer, $offset + 6, 2); $d['second'] = substr($buffer, $offset + 8, 2); if (checkdate($d['month'], $d['day'], $d['year'])) { $timestamp = mktime($d['hour'], $d['minute'], $d['second'], $d['month'], $d['day'], $d['year']); } // If all fails, assume one of the dozens of valid strtime() syntaxes (http://www.gnu.org/manual/tar-1.12/html_chapter/tar_7.html) } else { if (preg_match('/^[0-9]\\d{1,9}$/', $buffer)) { $timestamp = (int) $buffer; } else { $timestamp = strtotime($buffer); } } } // If all above failed, maybe it's a Unix timestamp already? if ($timestamp < 0 && preg_match('/^[1-9]\\d{1,9}$/', $buffer)) { $timestamp = $buffer; } // Reformat a valid timestamp if ($timestamp >= 0) { $timestamp -= $options[0] * 60 * 60; $source = $buffer; if ($options[2] == 'local') { $text = PMA_localisedDate($timestamp, $options[1]); } elseif ($options[2] == 'utc') { $text = gmdate($options[1], $timestamp); } else { $text = 'INVALID DATE TYPE'; } $buffer = '<dfn onclick="alert(\'' . $source . '\');" title="' . $source . '">' . $text . '</dfn>'; } return $buffer; }
echo $strShowStatusReset; ?> </a> <a href="<?php echo $cfg['MySQLManualBase']; ?> /server-status-variables.html" target="documentation">MySQL - <?php echo $strDocu; ?> </a> </div> <p> <?php echo sprintf($strServerStatusUptime, PMA_timespanFormat($server_status['Uptime']), PMA_localisedDate($start_time)) . "\n"; ?> </p> <div id="sectionlinks"> <?php foreach ($sections as $section_name => $section) { if (!empty($section['vars']) && !empty($section['title'])) { echo '<a href="' . PMA_getenv('PHP_SELF') . '?' . PMA_generate_common_url() . '#' . $section_name . '">' . $section['title'] . '</a>' . "\n"; } } ?> </div> <h3><?php echo $strServerTrafficNotes;
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $available_languages[$lang][2]; ?>" lang="<?php echo $available_languages[$lang][2]; ?>" dir="<?php echo $text_dir; ?>"> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>" /> <link rel="icon" href="./favicon.ico" type="image/x-icon" /> <link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" /> <title><?php echo $strSQLResult; ?> - phpMyAdmin <?php echo PMA_VERSION ?></title> <link rel="stylesheet" type="text/css" href="phpmyadmin.css.php?<?php echo PMA_generate_common_url('', ''); ?>&js_frame=print&nocache=<?php echo $_SESSION['PMA_Config']->getThemeUniqueValue(); ?>" /> </head> <body bgcolor="#ffffff"> <h1><?php echo $strSQLResult; ?></h1> <p> <strong><?php echo $strHost; ?>:</strong> <?php echo $cfg['Server']['verbose'] ? $cfg['Server']['verbose'] : $cfg['Server']['host'] . ((!empty($cfg['Server']['port'])) ? ':' . $cfg['Server']['port'] : ''); ?><br /> <strong><?php echo $strDatabase; ?>:</strong> <?php echo htmlspecialchars($db); ?><br /> <strong><?php echo $strGenTime; ?>:</strong> <?php echo PMA_localisedDate(); ?><br /> <strong><?php echo $strGenBy; ?>:</strong> phpMyAdmin <?php echo PMA_VERSION; ?> / MySQL <?php echo PMA_MYSQL_STR_VERSION; ?><br /> <strong><?php echo $strSQLQuery; ?>:</strong> <?php echo htmlspecialchars($full_sql_query); ?>; <?php if (isset($num_rows)) { ?><br /> <strong><?php echo $strRows; ?>:</strong> <?php echo $num_rows; ?> <?php } ?> </p> <?php /** * Sets a variable to remember headers have been sent */ $is_header_sent = TRUE; ?>
public function dataDictionaryDoc($alltables) { global $db, $pdf, $orientation, $paper; // TOC $pdf->addpage($_POST['orientation']); $pdf->Cell(0, 9, __('Table of contents'), 1, 0, 'C'); $pdf->Ln(15); $i = 1; foreach ($alltables as $table) { $pdf->PMA_links['doc'][$table]['-'] = $pdf->AddLink(); $pdf->SetX(10); // $pdf->Ln(1); $pdf->Cell(0, 6, __('Page number:') . ' {' . sprintf("%02d", $i) . '}', 0, 0, 'R', 0, $pdf->PMA_links['doc'][$table]['-']); $pdf->SetX(10); $pdf->Cell(0, 6, $i . ' ' . $table, 0, 1, 'L', 0, $pdf->PMA_links['doc'][$table]['-']); // $pdf->Ln(1); $fields = PMA_DBI_get_columns($GLOBALS['db'], $table); foreach ($fields as $row) { $pdf->SetX(20); $field_name = $row['Field']; $pdf->PMA_links['doc'][$table][$field_name] = $pdf->AddLink(); //$pdf->Cell( // 0, 6, $field_name, 0, 1, // 'L', 0, $pdf->PMA_links['doc'][$table][$field_name] //); } $i++; } $pdf->PMA_links['RT']['-'] = $pdf->AddLink(); $pdf->SetX(10); $pdf->Cell(0, 6, __('Page number:') . ' {00}', 0, 0, 'R', 0, $pdf->PMA_links['RT']['-']); $pdf->SetX(10); $pdf->Cell(0, 6, $i . ' ' . __('Relational schema'), 0, 1, 'L', 0, $pdf->PMA_links['RT']['-']); $z = 0; foreach ($alltables as $table) { $z++; $pdf->SetAutoPageBreak(true, 15); $pdf->addpage($_POST['orientation']); $pdf->Bookmark($table); $pdf->SetAlias('{' . sprintf("%02d", $z) . '}', $pdf->PageNo()); $pdf->PMA_links['RT'][$table]['-'] = $pdf->AddLink(); $pdf->SetLink($pdf->PMA_links['doc'][$table]['-'], -1); $pdf->SetFont($this->_ff, 'B', 18); $pdf->Cell(0, 8, $z . ' ' . $table, 1, 1, 'C', 0, $pdf->PMA_links['RT'][$table]['-']); $pdf->SetFont($this->_ff, '', 8); $pdf->ln(); $cfgRelation = PMA_getRelationsParam(); $comments = PMA_getComments($db, $table); if ($cfgRelation['mimework']) { $mime_map = PMA_getMIME($db, $table, true); } /** * Gets table informations */ $showtable = PMA_Table::sGetStatusInfo($db, $table); $show_comment = isset($showtable['Comment']) ? $showtable['Comment'] : ''; $create_time = isset($showtable['Create_time']) ? PMA_localisedDate(strtotime($showtable['Create_time'])) : ''; $update_time = isset($showtable['Update_time']) ? PMA_localisedDate(strtotime($showtable['Update_time'])) : ''; $check_time = isset($showtable['Check_time']) ? PMA_localisedDate(strtotime($showtable['Check_time'])) : ''; /** * Gets table keys and retains them */ $result = PMA_DBI_query('SHOW KEYS FROM ' . PMA_backquote($table) . ';'); $primary = ''; $indexes = array(); $lastIndex = ''; $indexes_info = array(); $indexes_data = array(); $pk_array = array(); // will be use to emphasis prim. keys in the table // view while ($row = PMA_DBI_fetch_assoc($result)) { // Backups the list of primary keys if ($row['Key_name'] == 'PRIMARY') { $primary .= $row['Column_name'] . ', '; $pk_array[$row['Column_name']] = 1; } // Retains keys informations if ($row['Key_name'] != $lastIndex) { $indexes[] = $row['Key_name']; $lastIndex = $row['Key_name']; } $indexes_info[$row['Key_name']]['Sequences'][] = $row['Seq_in_index']; $indexes_info[$row['Key_name']]['Non_unique'] = $row['Non_unique']; if (isset($row['Cardinality'])) { $indexes_info[$row['Key_name']]['Cardinality'] = $row['Cardinality']; } // I don't know what does following column mean.... // $indexes_info[$row['Key_name']]['Packed'] = $row['Packed']; $indexes_info[$row['Key_name']]['Comment'] = $row['Comment']; $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Column_name'] = $row['Column_name']; if (isset($row['Sub_part'])) { $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Sub_part'] = $row['Sub_part']; } } // end while if ($result) { PMA_DBI_free_result($result); } /** * Gets fields properties */ $columns = PMA_DBI_get_columns($db, $table); // Check if we can use Relations if (!empty($cfgRelation['relation'])) { // Find which tables are related with the current one and write it in // an array $res_rel = PMA_getForeigners($db, $table); if (count($res_rel) > 0) { $have_rel = true; } else { $have_rel = false; } } else { $have_rel = false; } // end if /** * Displays the comments of the table if MySQL >= 3.23 */ $break = false; if (!empty($show_comment)) { $pdf->Cell(0, 3, __('Table comments') . ' : ' . $show_comment, 0, 1); $break = true; } if (!empty($create_time)) { $pdf->Cell(0, 3, __('Creation') . ': ' . $create_time, 0, 1); $break = true; } if (!empty($update_time)) { $pdf->Cell(0, 3, __('Last update') . ': ' . $update_time, 0, 1); $break = true; } if (!empty($check_time)) { $pdf->Cell(0, 3, __('Last check') . ': ' . $check_time, 0, 1); $break = true; } if ($break == true) { $pdf->Cell(0, 3, '', 0, 1); $pdf->Ln(); } $pdf->SetFont($this->_ff, 'B'); if (isset($orientation) && $orientation == 'L') { $pdf->Cell(25, 8, __('Column'), 1, 0, 'C'); $pdf->Cell(20, 8, __('Type'), 1, 0, 'C'); $pdf->Cell(20, 8, __('Attributes'), 1, 0, 'C'); $pdf->Cell(10, 8, __('Null'), 1, 0, 'C'); $pdf->Cell(20, 8, __('Default'), 1, 0, 'C'); $pdf->Cell(25, 8, __('Extra'), 1, 0, 'C'); $pdf->Cell(45, 8, __('Links to'), 1, 0, 'C'); if ($paper == 'A4') { $comments_width = 67; } else { // this is really intended for 'letter' /** * @todo find optimal width for all formats */ $comments_width = 50; } $pdf->Cell($comments_width, 8, __('Comments'), 1, 0, 'C'); $pdf->Cell(45, 8, 'MIME', 1, 1, 'C'); $pdf->SetWidths(array(25, 20, 20, 10, 20, 25, 45, $comments_width, 45)); } else { $pdf->Cell(20, 8, __('Column'), 1, 0, 'C'); $pdf->Cell(20, 8, __('Type'), 1, 0, 'C'); $pdf->Cell(20, 8, __('Attributes'), 1, 0, 'C'); $pdf->Cell(10, 8, __('Null'), 1, 0, 'C'); $pdf->Cell(15, 8, __('Default'), 1, 0, 'C'); $pdf->Cell(15, 8, __('Extra'), 1, 0, 'C'); $pdf->Cell(30, 8, __('Links to'), 1, 0, 'C'); $pdf->Cell(30, 8, __('Comments'), 1, 0, 'C'); $pdf->Cell(30, 8, 'MIME', 1, 1, 'C'); $pdf->SetWidths(array(20, 20, 20, 10, 15, 15, 30, 30, 30)); } $pdf->SetFont($this->_ff, ''); foreach ($columns as $row) { $extracted_fieldspec = PMA_extractFieldSpec($row['Type']); $type = $extracted_fieldspec['print_type']; $attribute = $extracted_fieldspec['attribute']; if (!isset($row['Default'])) { if ($row['Null'] != '' && $row['Null'] != 'NO') { $row['Default'] = 'NULL'; } } $field_name = $row['Field']; // $pdf->Ln(); $pdf->PMA_links['RT'][$table][$field_name] = $pdf->AddLink(); $pdf->Bookmark($field_name, 1, -1); $pdf->SetLink($pdf->PMA_links['doc'][$table][$field_name], -1); $pdf_row = array($field_name, $type, $attribute, $row['Null'] == '' || $row['Null'] == 'NO' ? __('No') : __('Yes'), isset($row['Default']) ? $row['Default'] : '', $row['Extra'], isset($res_rel[$field_name]) ? $res_rel[$field_name]['foreign_table'] . ' -> ' . $res_rel[$field_name]['foreign_field'] : '', isset($comments[$field_name]) ? $comments[$field_name] : '', isset($mime_map) && isset($mime_map[$field_name]) ? str_replace('_', '/', $mime_map[$field_name]['mimetype']) : ''); $links[0] = $pdf->PMA_links['RT'][$table][$field_name]; if (isset($res_rel[$field_name]['foreign_table']) and isset($res_rel[$field_name]['foreign_field']) and isset($pdf->PMA_links['doc'][$res_rel[$field_name]['foreign_table']][$res_rel[$field_name]['foreign_field']])) { $links[6] = $pdf->PMA_links['doc'][$res_rel[$field_name]['foreign_table']][$res_rel[$field_name]['foreign_field']]; } else { unset($links[6]); } $pdf->Row($pdf_row, $links); } // end foreach $pdf->SetFont($this->_ff, '', 14); } //end each }
/** * Outputs export header * * @return bool Whether it succeeded * * @access public */ function PMA_exportHeader() { global $crlf; global $cfg; $head = '% phpMyAdmin LaTeX Dump' . $crlf . '% version ' . PMA_VERSION . $crlf . '% http://www.phpmyadmin.net' . $crlf . '%' . $crlf . '% ' . __('Host') . ': ' . $cfg['Server']['host']; if (!empty($cfg['Server']['port'])) { $head .= ':' . $cfg['Server']['port']; } $head .= $crlf . '% ' . __('Generation Time') . ': ' . PMA_localisedDate() . $crlf . '% ' . __('Server version') . ': ' . PMA_MYSQL_STR_VERSION . $crlf . '% ' . __('PHP Version') . ': ' . phpversion() . $crlf; return PMA_exportOutputHandler($head); }
?> <div id="statuslinks"> <a href="<?php echo $PMA_PHP_SELF . '?' . PMA_generate_common_url(); ?>" ><?php echo $strRefresh; ?></a> <a href="<?php echo $PMA_PHP_SELF . '?flush=STATUS&' . PMA_generate_common_url(); ?>" ><?php echo $strShowStatusReset; ?></a> <?php echo PMA_showMySQLDocu('server_status_variables','server_status_variables'); ?> </div> <p> <?php echo sprintf($strServerStatusUptime, PMA_timespanFormat($server_status['Uptime']), PMA_localisedDate($start_time)) . "\n"; ?> </p> <?php if ($server_master_status_run || $server_slave_status_run) { $replicationOut = ""; foreach ($replication_types as $type) { if (${"server_{$type}_status_run"}) { if ($replicationOut != "") { $replicationOut .= $strAndSmall . ' '; } $replicationOut .= '<b>' . $type . '</b> '; } } echo sprintf('<p>' . $strReplicationStatusInfo . '</p>', $replicationOut);
/** * Returns $table's CREATE definition * * @param string the database name * @param string the table name * @param string the end of line sequence * @param string the url to go back in case of error * @param boolean whether to include creation/update/check dates * * @return string resulting schema * * @global boolean whether to add 'drop' statements or not * @global boolean whether to use backquotes to allow the use of special * characters in database, table and fields names or not * * @access public */ function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false) { global $sql_drop_table; global $sql_backquotes; global $cfgRelation; global $sql_constraints; global $sql_constraints_query; // just the text of the query $schema_create = ''; $auto_increment = ''; $new_crlf = $crlf; // need to use PMA_DBI_QUERY_STORE with PMA_DBI_num_rows() in mysqli $result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . PMA_sqlAddslashes($table) . '\'', null, PMA_DBI_QUERY_STORE); if ($result != FALSE) { if (PMA_DBI_num_rows($result) > 0) { $tmpres = PMA_DBI_fetch_assoc($result); // Here we optionally add the AUTO_INCREMENT next value, // but starting with MySQL 5.0.24, the clause is already included // in SHOW CREATE TABLE so we'll remove it below if (isset($GLOBALS['sql_auto_increment']) && !empty($tmpres['Auto_increment'])) { $auto_increment .= ' AUTO_INCREMENT=' . $tmpres['Auto_increment'] . ' '; } if ($show_dates && isset($tmpres['Create_time']) && !empty($tmpres['Create_time'])) { $schema_create .= PMA_exportComment($GLOBALS['strStatCreateTime'] . ': ' . PMA_localisedDate(strtotime($tmpres['Create_time']))); $new_crlf = PMA_exportComment() . $crlf; } if ($show_dates && isset($tmpres['Update_time']) && !empty($tmpres['Update_time'])) { $schema_create .= PMA_exportComment($GLOBALS['strStatUpdateTime'] . ': ' . PMA_localisedDate(strtotime($tmpres['Update_time']))); $new_crlf = PMA_exportComment() . $crlf; } if ($show_dates && isset($tmpres['Check_time']) && !empty($tmpres['Check_time'])) { $schema_create .= PMA_exportComment($GLOBALS['strStatCheckTime'] . ': ' . PMA_localisedDate(strtotime($tmpres['Check_time']))); $new_crlf = PMA_exportComment() . $crlf; } } PMA_DBI_free_result($result); } $schema_create .= $new_crlf; // no need to generate a DROP VIEW here, it was done earlier if (!empty($sql_drop_table) && !PMA_Table::isView($db, $table)) { $schema_create .= 'DROP TABLE IF EXISTS ' . PMA_backquote($table, $sql_backquotes) . ';' . $crlf; } // Steve Alberty's patch for complete table dump, // Whether to quote table and fields names or not if ($sql_backquotes) { PMA_DBI_query('SET SQL_QUOTE_SHOW_CREATE = 1'); } else { PMA_DBI_query('SET SQL_QUOTE_SHOW_CREATE = 0'); } // I don't see the reason why this unbuffered query could cause problems, // because SHOW CREATE TABLE returns only one row, and we free the // results below. Nonetheless, we got 2 user reports about this // (see bug 1562533) so I remove the unbuffered mode. //$result = PMA_DBI_query('SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table), null, PMA_DBI_QUERY_UNBUFFERED); // // Note: SHOW CREATE TABLE, at least in MySQL 5.1.23, does not // produce a displayable result for the default value of a BIT // field, nor does the mysqldump command. See MySQL bug 35796 $result = PMA_DBI_query('SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table)); if ($result != FALSE && ($row = PMA_DBI_fetch_row($result))) { $create_query = $row[1]; unset($row); // Convert end of line chars to one that we want (note that MySQL doesn't return query it will accept in all cases) if (strpos($create_query, "(\r\n ")) { $create_query = str_replace("\r\n", $crlf, $create_query); } elseif (strpos($create_query, "(\n ")) { $create_query = str_replace("\n", $crlf, $create_query); } elseif (strpos($create_query, "(\r ")) { $create_query = str_replace("\r", $crlf, $create_query); } // Should we use IF NOT EXISTS? if (isset($GLOBALS['sql_if_not_exists'])) { $create_query = preg_replace('/^CREATE TABLE/', 'CREATE TABLE IF NOT EXISTS', $create_query); } // are there any constraints to cut out? if (preg_match('@CONSTRAINT|FOREIGN[\\s]+KEY@', $create_query)) { // Split the query into lines, so we can easily handle it. We know lines are separated by $crlf (done few lines above). $sql_lines = explode($crlf, $create_query); $sql_count = count($sql_lines); // lets find first line with constraints for ($i = 0; $i < $sql_count; $i++) { if (preg_match('@^[\\s]*(CONSTRAINT|FOREIGN[\\s]+KEY)@', $sql_lines[$i])) { break; } } // If we really found a constraint if ($i != $sql_count) { // remove , from the end of create statement $sql_lines[$i - 1] = preg_replace('@,$@', '', $sql_lines[$i - 1]); // prepare variable for constraints if (!isset($sql_constraints)) { if (isset($GLOBALS['no_constraints_comments'])) { $sql_constraints = ''; } else { $sql_constraints = $crlf . PMA_exportComment() . PMA_exportComment($GLOBALS['strConstraintsForDumped']) . PMA_exportComment(); } } // comments for current table if (!isset($GLOBALS['no_constraints_comments'])) { $sql_constraints .= $crlf . PMA_exportComment() . PMA_exportComment($GLOBALS['strConstraintsForTable'] . ' ' . PMA_backquote($table)) . PMA_exportComment(); } // let's do the work $sql_constraints_query .= 'ALTER TABLE ' . PMA_backquote($table) . $crlf; $sql_constraints .= 'ALTER TABLE ' . PMA_backquote($table) . $crlf; $first = TRUE; for ($j = $i; $j < $sql_count; $j++) { if (preg_match('@CONSTRAINT|FOREIGN[\\s]+KEY@', $sql_lines[$j])) { if (!$first) { $sql_constraints .= $crlf; } if (strpos($sql_lines[$j], 'CONSTRAINT') === FALSE) { $str_tmp = preg_replace('/(FOREIGN[\\s]+KEY)/', 'ADD \\1', $sql_lines[$j]); $sql_constraints_query .= $str_tmp; $sql_constraints .= $str_tmp; } else { $str_tmp = preg_replace('/(CONSTRAINT)/', 'ADD \\1', $sql_lines[$j]); $sql_constraints_query .= $str_tmp; $sql_constraints .= $str_tmp; } $first = FALSE; } else { break; } } $sql_constraints .= ';' . $crlf; $sql_constraints_query .= ';'; $create_query = implode($crlf, array_slice($sql_lines, 0, $i)) . $crlf . implode($crlf, array_slice($sql_lines, $j, $sql_count - 1)); unset($sql_lines); } } $schema_create .= $create_query; } // remove a possible "AUTO_INCREMENT = value" clause // that could be there starting with MySQL 5.0.24 $schema_create = preg_replace('/AUTO_INCREMENT\\s*=\\s*([0-9])+/', '', $schema_create); $schema_create .= $auto_increment; PMA_DBI_free_result($result); return $schema_create; }
/** * Returns $table's CREATE definition * * @param string the database name * @param string the table name * @param string the end of line sequence * @param string the url to go back in case of error * @param boolean whether to include creation/update/check dates * * @return string resulting schema * * @global boolean whether to add 'drop' statements or not * @global boolean whether to use backquotes to allow the use of special * characters in database, table and fields names or not * * @access public */ function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false) { global $drop; global $use_backquotes; global $cfgRelation; global $sql_constraints; $schema_create = ''; $auto_increment = ''; $new_crlf = $crlf; $result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . PMA_sqlAddslashes($table) . '\''); if ($result != FALSE) { if (PMA_DBI_num_rows($result) > 0) { $tmpres = PMA_DBI_fetch_assoc($result); if (isset($GLOBALS['auto_increment']) && !empty($tmpres['Auto_increment'])) { $auto_increment .= ' AUTO_INCREMENT=' . $tmpres['Auto_increment'] . ' '; } if ($show_dates && isset($tmpres['Create_time']) && !empty($tmpres['Create_time'])) { $schema_create .= $GLOBALS['comment_marker'] . $GLOBALS['strStatCreateTime'] . ': ' . PMA_localisedDate(strtotime($tmpres['Create_time'])) . $crlf; $new_crlf = $GLOBALS['comment_marker'] . $crlf . $crlf; } if ($show_dates && isset($tmpres['Update_time']) && !empty($tmpres['Update_time'])) { $schema_create .= $GLOBALS['comment_marker'] . $GLOBALS['strStatUpdateTime'] . ': ' . PMA_localisedDate(strtotime($tmpres['Update_time'])) . $crlf; $new_crlf = $GLOBALS['comment_marker'] . $crlf . $crlf; } if ($show_dates && isset($tmpres['Check_time']) && !empty($tmpres['Check_time'])) { $schema_create .= $GLOBALS['comment_marker'] . $GLOBALS['strStatCheckTime'] . ': ' . PMA_localisedDate(strtotime($tmpres['Check_time'])) . $crlf; $new_crlf = $GLOBALS['comment_marker'] . $crlf . $crlf; } } PMA_DBI_free_result($result); } $schema_create .= $new_crlf; if (!empty($drop)) { $schema_create .= 'DROP TABLE IF EXISTS ' . PMA_backquote($table, $use_backquotes) . ';' . $crlf; } // Steve Alberty's patch for complete table dump, // Whether to quote table and fields names or not if ($use_backquotes) { PMA_DBI_query('SET SQL_QUOTE_SHOW_CREATE = 1'); } else { PMA_DBI_query('SET SQL_QUOTE_SHOW_CREATE = 0'); } $result = PMA_DBI_query('SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table), NULL, PMA_DBI_QUERY_UNBUFFERED); if ($result != FALSE && ($row = PMA_DBI_fetch_row($result))) { $create_query = $row[1]; unset($row); // Convert end of line chars to one that we want (note that MySQL doesn't return query it will accept in all cases) if (strpos($create_query, "(\r\n ")) { $create_query = str_replace("\r\n", $crlf, $create_query); } elseif (strpos($create_query, "(\n ")) { $create_query = str_replace("\n", $crlf, $create_query); } elseif (strpos($create_query, "(\r ")) { $create_query = str_replace("\r", $crlf, $create_query); } // Should we use IF NOT EXISTS? if (isset($GLOBALS['if_not_exists'])) { $create_query = preg_replace('/^CREATE TABLE/', 'CREATE TABLE IF NOT EXISTS', $create_query); } // are there any constraints to cut out? if (preg_match('@CONSTRAINT|FOREIGN[\\s]+KEY@', $create_query)) { // Split the query into lines, so we can easily handle it. We know lines are separated by $crlf (done few lines above). $sql_lines = explode($crlf, $create_query); $sql_count = count($sql_lines); // lets find first line with constraints for ($i = 0; $i < $sql_count; $i++) { if (preg_match('@CONSTRAINT|FOREIGN[\\s]+KEY@', $sql_lines[$i])) { break; } } // remove , from the end of create statement $sql_lines[$i - 1] = preg_replace('@,$@', '', $sql_lines[$i - 1]); // prepare variable for constraints if (!isset($sql_constraints)) { if (isset($GLOBALS['no_constraints_comments'])) { $sql_constraints = ''; } else { $sql_constraints = $crlf . $GLOBALS['comment_marker'] . $crlf . $GLOBALS['comment_marker'] . $GLOBALS['strConstraintsForDumped'] . $crlf . $GLOBALS['comment_marker'] . $crlf; } } // comments for current table if (!isset($GLOBALS['no_constraints_comments'])) { $sql_constraints .= $crlf . $GLOBALS['comment_marker'] . $crlf . $GLOBALS['comment_marker'] . $GLOBALS['strConstraintsForTable'] . ' ' . PMA_backquote($table) . $crlf . $GLOBALS['comment_marker'] . $crlf; } // let's do the work $sql_constraints .= 'ALTER TABLE ' . PMA_backquote($table) . $crlf; $first = TRUE; for ($j = $i; $j < $sql_count; $j++) { if (preg_match('@CONSTRAINT|FOREIGN[\\s]+KEY@', $sql_lines[$j])) { if (!$first) { $sql_constraints .= $crlf; } if (strpos($sql_lines[$j], 'CONSTRAINT') === FALSE) { $sql_constraints .= preg_replace('/(FOREIGN[\\s]+KEY)/', 'ADD \\1', $sql_lines[$j]); } else { $sql_constraints .= preg_replace('/(CONSTRAINT)/', 'ADD \\1', $sql_lines[$j]); } $first = FALSE; } else { break; } } $sql_constraints .= ';' . $crlf; $create_query = implode($crlf, array_slice($sql_lines, 0, $i)) . $crlf . implode($crlf, array_slice($sql_lines, $j, $sql_count - 1)); unset($sql_lines); } $schema_create .= $create_query; } $schema_create .= $auto_increment; PMA_DBI_free_result($result); return $schema_create; }
if (isset($showtable['Update_time'])) { ?> <tr> <td><?php echo $strStatUpdateTime; ?></td> <td align="right"> <?php echo PMA_localisedDate(strtotime($showtable['Update_time'])) . "\n"; ?> </td> </tr> <?php } if (isset($showtable['Check_time'])) { ?> <tr> <td><?php echo $strStatCheckTime; ?></td> <td align="right"> <?php echo PMA_localisedDate(strtotime($showtable['Check_time'])) . "\n"; ?> </td> </tr> <?php } ?> </table> </td> </tr> </table> <?php } // end if ($nonisam == false) } // end if ($cfg['ShowStats']) }
} else { $num_tables = 1; $single = TRUE; } // No table -> error message if ($num_tables == 0) { echo '# ' . $strNoTablesFound; } else { // No csv format -> add some comments at the top if ($what != 'csv' && $what != 'excel') { $dump_buffer .= '# phpMyAdmin MySQL-Dump' . $crlf . '# version ' . PMA_VERSION . $crlf . '# http://phpwizard.net/phpMyAdmin/' . $crlf . '# http://phpmyadmin.sourceforge.net/ (download page)' . $crlf . '#' . $crlf . '# ' . $strHost . ': ' . $cfgServer['host']; if (!empty($cfgServer['port'])) { $dump_buffer .= ':' . $cfgServer['port']; } $formatted_db_name = isset($use_backquotes) ? PMA_backquote($db) : '\'' . $db . '\''; $dump_buffer .= $crlf . '# ' . $strGenTime . ': ' . PMA_localisedDate() . $crlf . '# ' . $strServerVersion . ': ' . substr(PMA_MYSQL_INT_VERSION, 0, 1) . '.' . substr(PMA_MYSQL_INT_VERSION, 1, 2) . '.' . substr(PMA_MYSQL_INT_VERSION, 3) . $crlf . '# ' . $strPHPVersion . ': ' . phpversion() . $crlf . '# ' . $strDatabase . ': ' . $formatted_db_name . $crlf; $i = 0; if (isset($table_select)) { $tmp_select = implode($table_select, '|'); $tmp_select = '|' . $tmp_select . '|'; } while ($i < $num_tables) { if (!isset($single)) { $table = mysql_tablename($tables, $i); } if (isset($tmp_select) && is_int(strpos($tmp_select, '|' . $table . '|')) == FALSE) { $i++; } else { $formatted_table_name = isset($use_backquotes) ? PMA_backquote($table) : '\'' . $table . '\''; // If only datas, no need to displays table name if ($what != 'dataonly') {
/** * Outputs export header * * @return bool Whether it suceeded * * @access public */ function PMA_exportHeader() { global $crlf; global $cfg; global $what; global $db; global $table; global $tables; $export_struct = isset($GLOBALS[$what . '_export_struc']) ? true : false; $export_data = isset($GLOBALS[$what . '_export_contents']) ? true : false; if ($GLOBALS['output_charset_conversion']) { $charset = $GLOBALS['charset_of_file']; } else { $charset = $GLOBALS['charset']; } $head = '<?xml version="1.0" encoding="' . $charset . '"?>' . $crlf . '<!--' . $crlf . '- phpMyAdmin XML Dump' . $crlf . '- version ' . PMA_VERSION . $crlf . '- http://www.phpmyadmin.net' . $crlf . '-' . $crlf . '- ' . $GLOBALS['strHost'] . ': ' . $cfg['Server']['host']; if (!empty($cfg['Server']['port'])) { $head .= ':' . $cfg['Server']['port']; } $head .= $crlf . '- ' . $GLOBALS['strGenTime'] . ': ' . PMA_localisedDate() . $crlf . '- ' . $GLOBALS['strServerVersion'] . ': ' . substr(PMA_MYSQL_INT_VERSION, 0, 1) . '.' . (int) substr(PMA_MYSQL_INT_VERSION, 1, 2) . '.' . (int) substr(PMA_MYSQL_INT_VERSION, 3) . $crlf . '- ' . $GLOBALS['strPHPVersion'] . ': ' . phpversion() . $crlf . '-->' . $crlf . $crlf; $head .= '<pma_xml_export version="1.0"' . ($export_struct ? ' xmlns:pma="http://www.phpmyadmin.net/some_doc_url/"' : '') . '>' . $crlf; if ($export_struct) { $result = PMA_DBI_fetch_result('SELECT `DEFAULT_CHARACTER_SET_NAME`, `DEFAULT_COLLATION_NAME` FROM `information_schema`.`SCHEMATA` WHERE `SCHEMA_NAME` = \'' . $db . '\' LIMIT 1'); $db_collation = $result[0]['DEFAULT_COLLATION_NAME']; $db_charset = $result[0]['DEFAULT_CHARACTER_SET_NAME']; $head .= ' <!--' . $crlf; $head .= ' - Structure schemas' . $crlf; $head .= ' -->' . $crlf; $head .= ' <pma:structure_schemas>' . $crlf; $head .= ' <pma:database name="' . $db . '" collation="' . $db_collation . '" charset="' . $db_charset . '">' . $crlf; if (count($tables) == 0) { $tables[] = $table; } foreach ($tables as $table) { // Export tables and views $result = PMA_DBI_fetch_result('SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table), 0); $tbl = $result[$table][1]; $is_view = PMA_isView($db, $table); if ($is_view) { $type = 'view'; } else { $type = 'table'; } if ($is_view && !isset($GLOBALS[$what . '_export_views'])) { continue; } if (!$is_view && !isset($GLOBALS[$what . '_export_tables'])) { continue; } $head .= ' <pma:' . $type . ' name="' . $table . '">' . $crlf; $tbl = " " . $tbl; $tbl = str_replace("\n", "\n ", $tbl); $head .= $tbl . ';' . $crlf; $head .= ' </pma:' . $type . '>' . $crlf; if (isset($GLOBALS[$what . '_export_triggers']) && $GLOBALS[$what . '_export_triggers']) { // Export triggers $triggers = PMA_DBI_get_triggers($db, $table); if ($triggers) { foreach ($triggers as $trigger) { $code = $trigger['create']; $head .= ' <pma:trigger name="' . $trigger['name'] . '">' . $crlf; // Do some formatting $code = substr(rtrim($code), 0, -3); $code = " " . $code; $code = str_replace("\n", "\n ", $code); $head .= $code . $crlf; $head .= ' </pma:trigger>' . $crlf; } unset($trigger); unset($triggers); } } } if (isset($GLOBALS[$what . '_export_functions']) && $GLOBALS[$what . '_export_functions']) { // Export functions $functions = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION'); if ($functions) { foreach ($functions as $function) { $head .= ' <pma:function name="' . $function . '">' . $crlf; // Do some formatting $sql = PMA_DBI_get_definition($db, 'FUNCTION', $function); $sql = rtrim($sql); $sql = " " . $sql; $sql = str_replace("\n", "\n ", $sql); $head .= $sql . $crlf; $head .= ' </pma:function>' . $crlf; } unset($create_func); unset($function); unset($functions); } } if (isset($GLOBALS[$what . '_export_procedures']) && $GLOBALS[$what . '_export_procedures']) { // Export procedures $procedures = PMA_DBI_get_procedures_or_functions($db, 'PROCEDURE'); if ($procedures) { foreach ($procedures as $procedure) { $head .= ' <pma:procedure name="' . $procedure . '">' . $crlf; // Do some formatting $sql = PMA_DBI_get_definition($db, 'PROCEDURE', $procedure); $sql = rtrim($sql); $sql = " " . $sql; $sql = str_replace("\n", "\n ", $sql); $head .= $sql . $crlf; $head .= ' </pma:procedure>' . $crlf; } unset($create_proc); unset($procedure); unset($procedures); } } unset($result); $head .= ' </pma:database>' . $crlf; $head .= ' </pma:structure_schemas>' . $crlf; if ($export_data) { $head .= $crlf; } } return PMA_exportOutputHandler($head); }
</td> </tr> <?php } if (isset($showtable['Check_time'])) { ?> <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?> "> <th class="name"><?php echo $strStatCheckTime; ?> </th> <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Check_time'])); ?> </td> </tr> <?php } ?> </tbody> </table> <?php } // END - Calc Table Space require './libraries/tbl_triggers.lib.php'; echo '<div class="clearfloat"></div>' . "\n"; /** * Displays the footer
</tr> <?php } if (isset($showtable['Update_time'])) { ?> <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>"> <th class="name"><?php echo $strStatUpdateTime; ?></th> <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Update_time'])); ?></td> </tr> <?php } if (isset($showtable['Check_time'])) { ?> <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>"> <th class="name"><?php echo $strStatCheckTime; ?></th> <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Check_time'])); ?></td> </tr> <?php } ?> </tbody> </table> <?php } // END - Calc Table Space require './libraries/tbl_triggers.lib.php'; echo '<div class="clearfloat"></div>' . "\n"; echo '</div>' . "\n"; echo '</div>' . "\n";
function Footer() { // This function must be named "Footer" to work with the FPDF library global $with_doc; if ($with_doc) { $this->SetY(-15); $this->SetFont('', '', 14); $this->Cell(0, 6, $GLOBALS['strPageNumber'] . ' ' . $this->PageNo() . '/{nb}', 'T', 0, 'C'); $this->Cell(0, 6, PMA_localisedDate(), 0, 1, 'R'); $this->SetY(20); } }
/** * Returns $table's CREATE definition * * @param string $db the database name * @param string $table the table name * @param string $crlf the end of line sequence * @param string $error_url the url to go back in case of error * @param bool $show_dates whether to include creation/update/check dates * @param bool $add_semicolon whether to add semicolon and end-of-line at the end * @param bool $view whether we're handling a view * @return string resulting schema * * @access public */ function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false, $add_semicolon = true, $view = false) { global $sql_drop_table; global $sql_backquotes; global $sql_constraints; global $sql_constraints_query; // just the text of the query global $sql_drop_foreign_keys; $schema_create = ''; $auto_increment = ''; $new_crlf = $crlf; // need to use PMA_DBI_QUERY_STORE with PMA_DBI_num_rows() in mysqli $result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . PMA_sqlAddSlashes($table, true) . '\'', null, PMA_DBI_QUERY_STORE); if ($result != false) { if (PMA_DBI_num_rows($result) > 0) { $tmpres = PMA_DBI_fetch_assoc($result); if (PMA_DRIZZLE && $show_dates) { // Drizzle doesn't give Create_time and Update_time in SHOW TABLE STATUS, add it $sql = "SELECT\n TABLE_CREATION_TIME AS Create_time,\n TABLE_UPDATE_TIME AS Update_time\n FROM data_dictionary.TABLES\n WHERE TABLE_SCHEMA = '" . PMA_sqlAddSlashes($db) . "'\n AND TABLE_NAME = '" . PMA_sqlAddSlashes($table) . "'"; $tmpres = array_merge(PMA_DBI_fetch_single_row($sql), $tmpres); } // Here we optionally add the AUTO_INCREMENT next value, // but starting with MySQL 5.0.24, the clause is already included // in SHOW CREATE TABLE so we'll remove it below // It's required for Drizzle because SHOW CREATE TABLE uses // the value from table's creation time if (isset($GLOBALS['sql_auto_increment']) && !empty($tmpres['Auto_increment'])) { $auto_increment .= ' AUTO_INCREMENT=' . $tmpres['Auto_increment'] . ' '; } if ($show_dates && isset($tmpres['Create_time']) && !empty($tmpres['Create_time'])) { $schema_create .= PMA_exportComment(__('Creation') . ': ' . PMA_localisedDate(strtotime($tmpres['Create_time']))); $new_crlf = PMA_exportComment() . $crlf; } if ($show_dates && isset($tmpres['Update_time']) && !empty($tmpres['Update_time'])) { $schema_create .= PMA_exportComment(__('Last update') . ': ' . PMA_localisedDate(strtotime($tmpres['Update_time']))); $new_crlf = PMA_exportComment() . $crlf; } if ($show_dates && isset($tmpres['Check_time']) && !empty($tmpres['Check_time'])) { $schema_create .= PMA_exportComment(__('Last check') . ': ' . PMA_localisedDate(strtotime($tmpres['Check_time']))); $new_crlf = PMA_exportComment() . $crlf; } } PMA_DBI_free_result($result); } $schema_create .= $new_crlf; // no need to generate a DROP VIEW here, it was done earlier if (!empty($sql_drop_table) && !PMA_Table::isView($db, $table)) { $schema_create .= 'DROP TABLE IF EXISTS ' . PMA_backquote($table, $sql_backquotes) . ';' . $crlf; } // Complete table dump, // Whether to quote table and column names or not // Drizzle always quotes names if (!PMA_DRIZZLE) { if ($sql_backquotes) { PMA_DBI_query('SET SQL_QUOTE_SHOW_CREATE = 1'); } else { PMA_DBI_query('SET SQL_QUOTE_SHOW_CREATE = 0'); } } // I don't see the reason why this unbuffered query could cause problems, // because SHOW CREATE TABLE returns only one row, and we free the // results below. Nonetheless, we got 2 user reports about this // (see bug 1562533) so I remove the unbuffered mode. //$result = PMA_DBI_query('SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table), null, PMA_DBI_QUERY_UNBUFFERED); // // Note: SHOW CREATE TABLE, at least in MySQL 5.1.23, does not // produce a displayable result for the default value of a BIT // column, nor does the mysqldump command. See MySQL bug 35796 $result = PMA_DBI_try_query('SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table)); // an error can happen, for example the table is crashed $tmp_error = PMA_DBI_getError(); if ($tmp_error) { return PMA_exportComment(__('in use') . '(' . $tmp_error . ')'); } if ($result != false && ($row = PMA_DBI_fetch_row($result))) { $create_query = $row[1]; unset($row); // Convert end of line chars to one that we want (note that MySQL doesn't return query it will accept in all cases) if (strpos($create_query, "(\r\n ")) { $create_query = str_replace("\r\n", $crlf, $create_query); } elseif (strpos($create_query, "(\n ")) { $create_query = str_replace("\n", $crlf, $create_query); } elseif (strpos($create_query, "(\r ")) { $create_query = str_replace("\r", $crlf, $create_query); } /* * Drop database name from VIEW creation. * * This is a bit tricky, but we need to issue SHOW CREATE TABLE with * database name, but we don't want name to show up in CREATE VIEW * statement. */ if ($view) { $create_query = preg_replace('/' . PMA_backquote($db) . '\\./', '', $create_query); } // Should we use IF NOT EXISTS? if (isset($GLOBALS['sql_if_not_exists'])) { $create_query = preg_replace('/^CREATE TABLE/', 'CREATE TABLE IF NOT EXISTS', $create_query); } // Drizzle (checked on 2011.03.13) returns ROW_FORMAT surrounded with quotes, which is not accepted by parser if (PMA_DRIZZLE) { $create_query = preg_replace('/ROW_FORMAT=\'(\\S+)\'/', 'ROW_FORMAT=$1', $create_query); } // are there any constraints to cut out? if (preg_match('@CONSTRAINT|FOREIGN[\\s]+KEY@', $create_query)) { // Split the query into lines, so we can easily handle it. We know lines are separated by $crlf (done few lines above). $sql_lines = explode($crlf, $create_query); $sql_count = count($sql_lines); // lets find first line with constraints for ($i = 0; $i < $sql_count; $i++) { if (preg_match('@^[\\s]*(CONSTRAINT|FOREIGN[\\s]+KEY)@', $sql_lines[$i])) { break; } } // If we really found a constraint if ($i != $sql_count) { // remove , from the end of create statement $sql_lines[$i - 1] = preg_replace('@,$@', '', $sql_lines[$i - 1]); // prepare variable for constraints if (!isset($sql_constraints)) { if (isset($GLOBALS['no_constraints_comments'])) { $sql_constraints = ''; } else { $sql_constraints = $crlf . PMA_exportComment() . PMA_exportComment(__('Constraints for dumped tables')) . PMA_exportComment(); } } // comments for current table if (!isset($GLOBALS['no_constraints_comments'])) { $sql_constraints .= $crlf . PMA_exportComment() . PMA_exportComment(__('Constraints for table') . ' ' . PMA_backquote($table)) . PMA_exportComment(); } // let's do the work $sql_constraints_query .= 'ALTER TABLE ' . PMA_backquote($table) . $crlf; $sql_constraints .= 'ALTER TABLE ' . PMA_backquote($table) . $crlf; $sql_drop_foreign_keys .= 'ALTER TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table) . $crlf; $first = true; for ($j = $i; $j < $sql_count; $j++) { if (preg_match('@CONSTRAINT|FOREIGN[\\s]+KEY@', $sql_lines[$j])) { if (!$first) { $sql_constraints .= $crlf; } if (strpos($sql_lines[$j], 'CONSTRAINT') === false) { $tmp_str = preg_replace('/(FOREIGN[\\s]+KEY)/', 'ADD \\1', $sql_lines[$j]); $sql_constraints_query .= $tmp_str; $sql_constraints .= $tmp_str; } else { $tmp_str = preg_replace('/(CONSTRAINT)/', 'ADD \\1', $sql_lines[$j]); $sql_constraints_query .= $tmp_str; $sql_constraints .= $tmp_str; preg_match('/(CONSTRAINT)([\\s])([\\S]*)([\\s])/', $sql_lines[$j], $matches); if (!$first) { $sql_drop_foreign_keys .= ', '; } $sql_drop_foreign_keys .= 'DROP FOREIGN KEY ' . $matches[3]; } $first = false; } else { break; } } $sql_constraints .= ';' . $crlf; $sql_constraints_query .= ';'; $create_query = implode($crlf, array_slice($sql_lines, 0, $i)) . $crlf . implode($crlf, array_slice($sql_lines, $j, $sql_count - 1)); unset($sql_lines); } } $schema_create .= $create_query; } // remove a possible "AUTO_INCREMENT = value" clause // that could be there starting with MySQL 5.0.24 // in Drizzle it's useless as it contains the value given at table creation time $schema_create = preg_replace('/AUTO_INCREMENT\\s*=\\s*([0-9])+/', '', $schema_create); $schema_create .= $auto_increment; PMA_DBI_free_result($result); return $schema_create . ($add_semicolon ? ';' . $crlf : ''); }
<a href="<?php echo $PMA_PHP_SELF . '?flush=STATUS&' . PMA_generate_common_url(); ?> " ><?php echo _pgettext('for Show status', 'Reset'); ?> </a> <?php echo PMA_showMySQLDocu('server_status_variables', 'server_status_variables'); ?> </div> <p> <?php echo sprintf(__('This MySQL server has been running for %s. It started up on %s.'), PMA_timespanFormat($server_status['Uptime']), PMA_localisedDate($start_time)) . "\n"; ?> </p> <?php if ($server_master_status || $server_slave_status) { echo '<p>'; if ($server_master_status && $server_slave_status) { echo __('This MySQL server works as <b>master</b> and <b>slave</b> in <b>replication</b> process.'); } elseif ($server_master_status) { echo __('This MySQL server works as <b>master</b> in <b>replication</b> process.'); } elseif ($server_slave_status) { echo __('This MySQL server works as <b>slave</b> in <b>replication</b> process.'); } echo ' '; echo __('For further information about replication status on the server, please visit the <a href=#replication>replication section</a>.');
public function dataDictionaryDoc($alltables) { global $db, $pdf, $orientation, $paper; // TOC $pdf->addpage($GLOBALS['orientation']); $pdf->Cell(0, 9, __('Table of contents'), 1, 0, 'C'); $pdf->Ln(15); $i = 1; foreach ($alltables as $table) { $pdf->PMA_links['doc'][$table]['-'] = $pdf->AddLink(); $pdf->SetX(10); // $pdf->Ln(1); $pdf->Cell(0, 6, __('Page number:') . ' {' . sprintf("%02d", $i + 1) . '}', 0, 0, 'R', 0, $pdf->PMA_links['doc'][$table]['-']); $pdf->SetX(10); $pdf->Cell(0, 6, $i . ' ' . $table, 0, 1, 'L', 0, $pdf->PMA_links['doc'][$table]['-']); // $pdf->Ln(1); $result = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';'); while ($row = PMA_DBI_fetch_assoc($result)) { $pdf->SetX(20); $field_name = $row['Field']; $pdf->PMA_links['doc'][$table][$field_name] = $pdf->AddLink(); // $pdf->Cell(0, 6, $field_name,0,1,'L',0, $pdf->PMA_links['doc'][$table][$field_name]); } $lasttable = $table; $i++; } $pdf->PMA_links['RT']['-'] = $pdf->AddLink(); $pdf->SetX(10); $pdf->Cell(0, 6, __('Page number:') . ' {' . sprintf("%02d", $i + 1) . '}', 0, 0, 'R', 0, $pdf->PMA_links['RT']['-']); $pdf->SetX(10); $pdf->Cell(0, 6, $i . ' ' . __('Relational schema'), 0, 1, 'L', 0, $pdf->PMA_links['RT']['-']); $z = 0; foreach ($alltables as $table) { $z++; $pdf->SetAutoPageBreak(true, 15); $pdf->addpage($GLOBALS['orientation']); $pdf->Bookmark($table); $pdf->SetAlias('{' . sprintf("%02d", $z) . '}', $pdf->PageNo()); $pdf->PMA_links['RT'][$table]['-'] = $pdf->AddLink(); $pdf->SetLink($pdf->PMA_links['doc'][$table]['-'], -1); $pdf->SetFont($this->_ff, 'B', 18); $pdf->Cell(0, 8, $z . ' ' . $table, 1, 1, 'C', 0, $pdf->PMA_links['RT'][$table]['-']); $pdf->SetFont($this->_ff, '', 8); $pdf->ln(); $cfgRelation = PMA_getRelationsParam(); $comments = PMA_getComments($db, $table); if ($cfgRelation['mimework']) { $mime_map = PMA_getMIME($db, $table, true); } /** * Gets table informations */ $showtable = PMA_Table::sGetStatusInfo($db, $table); $num_rows = isset($showtable['Rows']) ? $showtable['Rows'] : 0; $show_comment = isset($showtable['Comment']) ? $showtable['Comment'] : ''; $create_time = isset($showtable['Create_time']) ? PMA_localisedDate(strtotime($showtable['Create_time'])) : ''; $update_time = isset($showtable['Update_time']) ? PMA_localisedDate(strtotime($showtable['Update_time'])) : ''; $check_time = isset($showtable['Check_time']) ? PMA_localisedDate(strtotime($showtable['Check_time'])) : ''; /** * Gets table keys and retains them */ $result = PMA_DBI_query('SHOW KEYS FROM ' . PMA_backquote($table) . ';'); $primary = ''; $indexes = array(); $lastIndex = ''; $indexes_info = array(); $indexes_data = array(); $pk_array = array(); // will be use to emphasis prim. keys in the table // view while ($row = PMA_DBI_fetch_assoc($result)) { // Backups the list of primary keys if ($row['Key_name'] == 'PRIMARY') { $primary .= $row['Column_name'] . ', '; $pk_array[$row['Column_name']] = 1; } // Retains keys informations if ($row['Key_name'] != $lastIndex) { $indexes[] = $row['Key_name']; $lastIndex = $row['Key_name']; } $indexes_info[$row['Key_name']]['Sequences'][] = $row['Seq_in_index']; $indexes_info[$row['Key_name']]['Non_unique'] = $row['Non_unique']; if (isset($row['Cardinality'])) { $indexes_info[$row['Key_name']]['Cardinality'] = $row['Cardinality']; } // I don't know what does following column mean.... // $indexes_info[$row['Key_name']]['Packed'] = $row['Packed']; $indexes_info[$row['Key_name']]['Comment'] = $row['Comment']; $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Column_name'] = $row['Column_name']; if (isset($row['Sub_part'])) { $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Sub_part'] = $row['Sub_part']; } } // end while if ($result) { PMA_DBI_free_result($result); } /** * Gets fields properties */ $result = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE); $fields_cnt = PMA_DBI_num_rows($result); // Check if we can use Relations (Mike Beck) if (!empty($cfgRelation['relation'])) { // Find which tables are related with the current one and write it in // an array $res_rel = PMA_getForeigners($db, $table); if (count($res_rel) > 0) { $have_rel = true; } else { $have_rel = false; } } else { $have_rel = false; } // end if /** * Displays the comments of the table if MySQL >= 3.23 */ $break = false; if (!empty($show_comment)) { $pdf->Cell(0, 3, __('Table comments') . ' : ' . $show_comment, 0, 1); $break = true; } if (!empty($create_time)) { $pdf->Cell(0, 3, __('Creation') . ': ' . $create_time, 0, 1); $break = true; } if (!empty($update_time)) { $pdf->Cell(0, 3, __('Last update') . ': ' . $update_time, 0, 1); $break = true; } if (!empty($check_time)) { $pdf->Cell(0, 3, __('Last check') . ': ' . $check_time, 0, 1); $break = true; } if ($break == true) { $pdf->Cell(0, 3, '', 0, 1); $pdf->Ln(); } $pdf->SetFont($this->_ff, 'B'); if (isset($orientation) && $orientation == 'L') { $pdf->Cell(25, 8, ucfirst(__('Column')), 1, 0, 'C'); $pdf->Cell(20, 8, ucfirst(__('Type')), 1, 0, 'C'); $pdf->Cell(20, 8, ucfirst(__('Attributes')), 1, 0, 'C'); $pdf->Cell(10, 8, ucfirst(__('Null')), 1, 0, 'C'); $pdf->Cell(20, 8, ucfirst(__('Default')), 1, 0, 'C'); $pdf->Cell(25, 8, ucfirst(__('Extra')), 1, 0, 'C'); $pdf->Cell(45, 8, ucfirst(__('Links to')), 1, 0, 'C'); if ($paper == 'A4') { $comments_width = 67; } else { // this is really intended for 'letter' /** * @todo find optimal width for all formats */ $comments_width = 50; } $pdf->Cell($comments_width, 8, ucfirst(__('Comments')), 1, 0, 'C'); $pdf->Cell(45, 8, 'MIME', 1, 1, 'C'); $pdf->SetWidths(array(25, 20, 20, 10, 20, 25, 45, $comments_width, 45)); } else { $pdf->Cell(20, 8, ucfirst(__('Column')), 1, 0, 'C'); $pdf->Cell(20, 8, ucfirst(__('Type')), 1, 0, 'C'); $pdf->Cell(20, 8, ucfirst(__('Attributes')), 1, 0, 'C'); $pdf->Cell(10, 8, ucfirst(__('Null')), 1, 0, 'C'); $pdf->Cell(15, 8, ucfirst(__('Default')), 1, 0, 'C'); $pdf->Cell(15, 8, ucfirst(__('Extra')), 1, 0, 'C'); $pdf->Cell(30, 8, ucfirst(__('Links to')), 1, 0, 'C'); $pdf->Cell(30, 8, ucfirst(__('Comments')), 1, 0, 'C'); $pdf->Cell(30, 8, 'MIME', 1, 1, 'C'); $pdf->SetWidths(array(20, 20, 20, 10, 15, 15, 30, 30, 30)); } $pdf->SetFont($this->_ff, ''); while ($row = PMA_DBI_fetch_assoc($result)) { $type = $row['Type']; // reformat mysql query output // set or enum types: slashes single quotes inside options if (preg_match('@^(set|enum)\\((.+)\\)$@i', $type, $tmp)) { $tmp[2] = substr(preg_replace("@([^,])''@", "\\1\\'", ',' . $tmp[2]), 1); $type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')'; $type_nowrap = ''; $binary = 0; $unsigned = 0; $zerofill = 0; } else { $type_nowrap = ' nowrap="nowrap"'; $type = preg_replace('@BINARY@i', '', $type); $type = preg_replace('@ZEROFILL@i', '', $type); $type = preg_replace('@UNSIGNED@i', '', $type); if (empty($type)) { $type = ' '; } $binary = stristr($row['Type'], 'BINARY'); $unsigned = stristr($row['Type'], 'UNSIGNED'); $zerofill = stristr($row['Type'], 'ZEROFILL'); } $attribute = ' '; if ($binary) { $attribute = 'BINARY'; } if ($unsigned) { $attribute = 'UNSIGNED'; } if ($zerofill) { $attribute = 'UNSIGNED ZEROFILL'; } if (!isset($row['Default'])) { if ($row['Null'] != '' && $row['Null'] != 'NO') { $row['Default'] = 'NULL'; } } $field_name = $row['Field']; // $pdf->Ln(); $pdf->PMA_links['RT'][$table][$field_name] = $pdf->AddLink(); $pdf->Bookmark($field_name, 1, -1); $pdf->SetLink($pdf->PMA_links['doc'][$table][$field_name], -1); $pdf_row = array($field_name, $type, $attribute, $row['Null'] == '' || $row['Null'] == 'NO' ? __('No') : __('Yes'), isset($row['Default']) ? $row['Default'] : '', $row['Extra'], isset($res_rel[$field_name]) ? $res_rel[$field_name]['foreign_table'] . ' -> ' . $res_rel[$field_name]['foreign_field'] : '', isset($comments[$field_name]) ? $comments[$field_name] : '', isset($mime_map) && isset($mime_map[$field_name]) ? str_replace('_', '/', $mime_map[$field_name]['mimetype']) : ''); $links[0] = $pdf->PMA_links['RT'][$table][$field_name]; if (isset($res_rel[$field_name]['foreign_table']) and isset($res_rel[$field_name]['foreign_field']) and isset($pdf->PMA_links['doc'][$res_rel[$field_name]['foreign_table']][$res_rel[$field_name]['foreign_field']])) { $links[6] = $pdf->PMA_links['doc'][$res_rel[$field_name]['foreign_table']][$res_rel[$field_name]['foreign_field']]; } else { unset($links[6]); } $pdf->Row($pdf_row, $links); } // end while $pdf->SetFont($this->_ff, '', 14); PMA_DBI_free_result($result); } //end each }
/** * localised date test, globals are defined * @dataProvider localisedDateDataProvider */ public function testLocalisedDate($a, $b, $e) { $this->assertEquals($e, PMA_localisedDate($a, $b)); }
<td align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Update_time'])); ?> </td> </tr> <?php } if (!empty($sts_data['Check_time'])) { ?> <tr> <td align="right"><?php echo $strStatCheckTime . ': '; ?> </td> <td align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Check_time'])); ?> </td> </tr> <?php } ?> </table> <?php } ?> </td> </tr> <?php } ?>
function printServerTraffic() { global $server_status, $PMA_PHP_SELF; global $server_master_status, $server_slave_status, $replication_types; $hour_factor = 3600 / $server_status['Uptime']; /** * starttime calculation */ $start_time = PMA_DBI_fetch_value('SELECT UNIX_TIMESTAMP() - ' . $server_status['Uptime']); ?> <h3><?php echo sprintf(__('Network traffic since startup: %s'), implode(' ', PMA_formatByteDown($server_status['Bytes_received'] + $server_status['Bytes_sent'], 3, 1))); ?> </h3> <p> <?php echo sprintf(__('This MySQL server has been running for %1$s. It started up on %2$s.'), PMA_timespanFormat($server_status['Uptime']), PMA_localisedDate($start_time)) . "\n"; ?> </p> <?php if ($server_master_status || $server_slave_status) { echo '<p class="notice">'; if ($server_master_status && $server_slave_status) { echo __('This MySQL server works as <b>master</b> and <b>slave</b> in <b>replication</b> process.'); } elseif ($server_master_status) { echo __('This MySQL server works as <b>master</b> in <b>replication</b> process.'); } elseif ($server_slave_status) { echo __('This MySQL server works as <b>slave</b> in <b>replication</b> process.'); } echo ' '; echo __('For further information about replication status on the server, please visit the <a href="#replication">replication section</a>.'); echo '</p>'; } /* if the server works as master or slave in replication process, display useful information */ if ($server_master_status || $server_slave_status) { ?> <hr class="clearfloat" /> <h3><a name="replication"></a><?php echo __('Replication status'); ?> </h3> <?php foreach ($replication_types as $type) { if (${"server_{$type}_status"}) { PMA_replication_print_status_table($type); } } unset($types); } ?> <table id="serverstatustraffic" class="data noclick"> <thead> <tr> <th colspan="2"><?php echo __('Traffic') . ' ' . PMA_showHint(__('On a busy server, the byte counters may overrun, so those statistics as reported by the MySQL server may be incorrect.')); ?> </th> <th>ø <?php echo __('per hour'); ?> </th> </tr> </thead> <tbody> <tr class="odd"> <th class="name"><?php echo __('Received'); ?> </th> <td class="value"><?php echo implode(' ', PMA_formatByteDown($server_status['Bytes_received'], 3, 1)); ?> </td> <td class="value"><?php echo implode(' ', PMA_formatByteDown($server_status['Bytes_received'] * $hour_factor, 3, 1)); ?> </td> </tr> <tr class="even"> <th class="name"><?php echo __('Sent'); ?> </th> <td class="value"><?php echo implode(' ', PMA_formatByteDown($server_status['Bytes_sent'], 3, 1)); ?> </td> <td class="value"><?php echo implode(' ', PMA_formatByteDown($server_status['Bytes_sent'] * $hour_factor, 3, 1)); ?> </td> </tr> <tr class="odd"> <th class="name"><?php echo __('Total'); ?> </th> <td class="value"><?php echo implode(' ', PMA_formatByteDown($server_status['Bytes_received'] + $server_status['Bytes_sent'], 3, 1)); ?> </td> <td class="value"><?php echo implode(' ', PMA_formatByteDown(($server_status['Bytes_received'] + $server_status['Bytes_sent']) * $hour_factor, 3, 1)); ?> </td> </tr> </tbody> </table> <table id="serverstatusconnections" class="data noclick"> <thead> <tr> <th colspan="2"><?php echo __('Connections'); ?> </th> <th>ø <?php echo __('per hour'); ?> </th> <th>%</th> </tr> </thead> <tbody> <tr class="odd"> <th class="name"><?php echo __('max. concurrent connections'); ?> </th> <td class="value"><?php echo PMA_formatNumber($server_status['Max_used_connections'], 0); ?> </td> <td class="value">--- </td> <td class="value">--- </td> </tr> <tr class="even"> <th class="name"><?php echo __('Failed attempts'); ?> </th> <td class="value"><?php echo PMA_formatNumber($server_status['Aborted_connects'], 4, 1, true); ?> </td> <td class="value"><?php echo PMA_formatNumber($server_status['Aborted_connects'] * $hour_factor, 4, 2, true); ?> </td> <td class="value"><?php echo $server_status['Connections'] > 0 ? PMA_formatNumber($server_status['Aborted_connects'] * 100 / $server_status['Connections'], 0, 2, true) . '%' : '--- '; ?> </td> </tr> <tr class="odd"> <th class="name"><?php echo __('Aborted'); ?> </th> <td class="value"><?php echo PMA_formatNumber($server_status['Aborted_clients'], 4, 1, true); ?> </td> <td class="value"><?php echo PMA_formatNumber($server_status['Aborted_clients'] * $hour_factor, 4, 2, true); ?> </td> <td class="value"><?php echo $server_status['Connections'] > 0 ? PMA_formatNumber($server_status['Aborted_clients'] * 100 / $server_status['Connections'], 0, 2, true) . '%' : '--- '; ?> </td> </tr> <tr class="even"> <th class="name"><?php echo __('Total'); ?> </th> <td class="value"><?php echo PMA_formatNumber($server_status['Connections'], 4, 0); ?> </td> <td class="value"><?php echo PMA_formatNumber($server_status['Connections'] * $hour_factor, 4, 2); ?> </td> <td class="value"><?php echo PMA_formatNumber(100, 0, 2); ?> %</td> </tr> </tbody> </table> <?php $url_params = array(); $show_full_sql = !empty($_REQUEST['full']); if ($show_full_sql) { $url_params['full'] = 1; $full_text_link = 'server_status.php' . PMA_generate_common_url(array(), 'html', '?'); } else { $full_text_link = 'server_status.php' . PMA_generate_common_url(array('full' => 1)); } if (PMA_DRIZZLE) { $sql_query = "SELECT\n p.id AS Id,\n p.username AS User,\n p.host AS Host,\n p.db AS db,\n p.command AS Command,\n p.time AS Time,\n p.state AS State,\n " . ($show_full_sql ? 's.query' : 'left(p.info, ' . (int) $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] . ')') . " AS Info\n FROM data_dictionary.PROCESSLIST p\n " . ($show_full_sql ? 'LEFT JOIN data_dictionary.SESSIONS s ON s.session_id = p.id' : ''); } else { $sql_query = $show_full_sql ? 'SHOW FULL PROCESSLIST' : 'SHOW PROCESSLIST'; } $result = PMA_DBI_query($sql_query); /** * Displays the page */ ?> <table id="tableprocesslist" class="data clearfloat noclick"> <thead> <tr> <th><?php echo __('Processes'); ?> </th> <th><?php echo __('ID'); ?> </th> <th><?php echo __('User'); ?> </th> <th><?php echo __('Host'); ?> </th> <th><?php echo __('Database'); ?> </th> <th><?php echo __('Command'); ?> </th> <th><?php echo __('Time'); ?> </th> <th><?php echo __('Status'); ?> </th> <th><?php echo __('SQL query'); if (!PMA_DRIZZLE) { ?> <a href="<?php echo $full_text_link; ?> " title="<?php echo $show_full_sql ? __('Truncate Shown Queries') : __('Show Full Queries'); ?> "> <img src="<?php echo $GLOBALS['pmaThemeImage'] . 's_' . ($show_full_sql ? 'partial' : 'full'); ?> text.png" alt="<?php echo $show_full_sql ? __('Truncate Shown Queries') : __('Show Full Queries'); ?> " /> </a> <?php } ?> </th> </tr> </thead> <tbody> <?php $odd_row = true; while ($process = PMA_DBI_fetch_assoc($result)) { $url_params['kill'] = $process['Id']; $kill_process = 'server_status.php' . PMA_generate_common_url($url_params); ?> <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?> "> <td><a href="<?php echo $kill_process; ?> "><?php echo __('Kill'); ?> </a></td> <td class="value"><?php echo $process['Id']; ?> </td> <td><?php echo $process['User']; ?> </td> <td><?php echo $process['Host']; ?> </td> <td><?php echo !isset($process['db']) || !strlen($process['db']) ? '<i>' . __('None') . '</i>' : $process['db']; ?> </td> <td><?php echo $process['Command']; ?> </td> <td class="value"><?php echo $process['Time']; ?> </td> <td><?php echo empty($process['State']) ? '---' : $process['State']; ?> </td> <td> <?php if (empty($process['Info'])) { echo '---'; } else { if (!$show_full_sql && strlen($process['Info']) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) { echo htmlspecialchars(substr($process['Info'], 0, $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'])) . '[...]'; } else { echo PMA_SQP_formatHtml(PMA_SQP_parse($process['Info'])); } } ?> </td> </tr> <?php $odd_row = !$odd_row; } ?> </tbody> </table> <?php }
:</strong> <?php echo $cfg['Server']['verbose'] ? $cfg['Server']['verbose'] : $cfg['Server']['host'] . (!empty($cfg['Server']['port']) ? ':' . $cfg['Server']['port'] : ''); ?> <br /> <strong><?php echo $strDatabase; ?> :</strong> <?php echo htmlspecialchars($db); ?> <br /> <strong><?php echo $strGenTime; ?> :</strong> <?php echo PMA_localisedDate(); ?> <br /> <strong><?php echo $strGenBy; ?> :</strong> phpMyAdmin <?php echo PMA_VERSION; ?> / MySQL <?php echo PMA_MYSQL_STR_VERSION; ?> <br /> <strong><?php echo $strSQLQuery; ?>
// Get additional information about tables for tooltip if ($cfg['ShowTooltip']) { $tooltip_truename = array(); $tooltip_aliasname = array(); $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db)); while ($tmp = PMA_mysql_fetch_array($result)) { $tooltip_truename[$tmp['Name']] = $cfg['ShowTooltipAliasTB'] ? !empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : $tmp['Name'] : $tmp['Name']; $tooltip_aliasname[$tmp['Name']] = $cfg['ShowTooltipAliasTB'] ? $tmp['Name'] : (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : ''); if (isset($tmp['Create_time']) && !empty($tmp['Create_time'])) { $tooltip_aliasname[$tmp['Name']] .= ', ' . $strStatCreateTime . ': ' . PMA_localisedDate(strtotime($tmp['Create_time'])); } if (isset($tmp['Update_time']) && !empty($tmp['Update_time'])) { $tooltip_aliasname[$tmp['Name']] .= ', ' . $strStatUpdateTime . ': ' . PMA_localisedDate(strtotime($tmp['Update_time'])); } if (isset($tmp['Check_time']) && !empty($tmp['Check_time'])) { $tooltip_aliasname[$tmp['Name']] .= ', ' . $strStatCheckTime . ': ' . PMA_localisedDate(strtotime($tmp['Check_time'])); } } // end while } // end if if ($cfgRelation['commwork']) { $comment = PMA_getComments($db); /** * Displays table comment */ if (is_array($comment)) { ?> <!-- DB comment --> <p><i> <?php