Merge branch 'master' of git://phpmyadmin.git.sourceforge.net/gitroot/phpmyadmin/phpmyadmin into OpenGIS

Conflicts:
	libraries/common.lib.php
This commit is contained in:
Madhura Jayaratne 2011-08-08 07:45:53 +05:30
commit 0e84927693
221 changed files with 74067 additions and 63383 deletions

View File

@ -4,7 +4,7 @@ phpMyAdmin - ChangeLog
3.5.0.0 (not yet released)
+ rfe #2021981 [interface] Add support for mass prefix change.
+ "up to date" message on main page when current version is up to date
+ Update to jQuery 1.6.1
+ Update to jQuery 1.6.2
+ Patch #3256122 [search] Show/hide db search results
+ Patch #3302354 Add gettext wrappers around a message
+ Remove deprecated function PMA_DBI_get_fields
@ -46,6 +46,8 @@ phpMyAdmin - ChangeLog
- bug #3375325 [interface] Page list in navigation frame looks odd
- bug #3313235 [interface] Error div misplaced
- bug #3374802 [interface] Comment on a column breaks inline editing
- patch #3383711 [display] Order by a column in a view doesn't work in some cases
- bug #3386434 [interface] Add missing space to server status
3.4.4.0 (not yet released)
- bug #3323060 [parser] SQL parser breaks AJAX requests if query has unclosed quotes

View File

@ -3095,6 +3095,7 @@ RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization},L]
<li><a href="http://www.hardened-php.net/suhosin/configuration.html#suhosin.post.max_array_index_length">suhosin.post.max_array_index_length</a> should be increased (eg. 256)</li>
<li><a href="http://www.hardened-php.net/suhosin/configuration.html#suhosin.request.max_totalname_length">suhosin.request.max_totalname_length</a> should be increased (eg. 8192)</li>
<li><a href="http://www.hardened-php.net/suhosin/configuration.html#suhosin.post.max_totalname_length">suhosin.post.max_totalname_length</a> should be increased (eg. 8192)</li>
<li><a href="http://www.hardened-php.net/suhosin/configuration.html#suhosin.get.max_value_length">suhosin.get.max_value_length</a> should be increased (eg. 1024)</li>
<li><a href="http://www.hardened-php.net/suhosin/configuration.html#suhosin.sql.bailout_on_error">suhosin.sql.bailout_on_error</a> needs to be disabled (the default)</li>
<li><a href="http://www.hardened-php.net/suhosin/configuration.html#logging_configuration">suhosin.log.*</a> should not include SQL, otherwise you get big slowdown</li>
</ul>

View File

@ -43,14 +43,7 @@ if ($fHnd === false) {
$f_size = $hdrs['Content-Length'];
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Content-type: $c_type");
header('Content-length: ' . $f_size);
header("Content-disposition: attachment; filename=" . basename($filename));
PMA_download_header(basename($filename), $c_type, $f_size);
$pos = 0;
$content = "";

View File

@ -1,34 +0,0 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* "Echo" service to allow force downloading of exported charts (png or svg)
*
* @package phpMyAdmin
*/
define('PMA_MINIMUM_COMMON', true);
require_once './libraries/common.inc.php';
if (isset($_REQUEST['filename']) && isset($_REQUEST['image'])) {
$allowed = Array( 'image/png'=>'png', 'image/svg+xml'=>'svg');
if (! isset($allowed[$_REQUEST['type']])) exit('Invalid export type');
if (! preg_match("/(".implode("|",$allowed).")$/i", $_REQUEST['filename']))
$_REQUEST['filename'] .= '.' . $allowed[$_REQUEST['type']];
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=".$_REQUEST['filename']);
header("Content-Type: ".$_REQUEST['type']);
header("Content-Transfer-Encoding: binary");
if ($allowed[$_REQUEST['type']] != 'svg')
echo base64_decode(substr($_REQUEST['image'], strpos($_REQUEST['image'],',') + 1));
else
echo $_REQUEST['image'];
} else exit('Invalid request');
?>

View File

@ -119,8 +119,8 @@ while ($row = PMA_DBI_fetch_row($rowset)) {
/**
* Gets columns properties
*/
$result = PMA_DBI_query('SHOW COLUMNS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE);
$fields_cnt = PMA_DBI_num_rows($result);
$columns = PMA_DBI_get_columns($db, $table);
$fields_cnt = count($columns);
if (PMA_MYSQL_INT_VERSION < 50025) {
// We need this to correctly learn if a TIMESTAMP is NOT NULL, since
@ -181,44 +181,22 @@ while ($row = PMA_DBI_fetch_row($rowset)) {
</tr>
<?php
$odd_row = true;
while ($row = PMA_DBI_fetch_assoc($result)) {
foreach ($columns as $row) {
if ($row['Null'] == '') {
$row['Null'] = 'NO';
}
$type = $row['Type'];
$extracted_fieldspec = PMA_extractFieldSpec($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]) . ')';
if ('set' == $extracted_fieldspec['type'] || 'enum' == $extracted_fieldspec['type']) {
$type_nowrap = '';
$binary = 0;
$unsigned = 0;
$zerofill = 0;
} else {
$binary = stristr($row['Type'], 'binary');
$unsigned = stristr($row['Type'], 'unsigned');
$zerofill = stristr($row['Type'], 'zerofill');
$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 = ' ';
}
}
$attribute = ' ';
if ($binary) {
$attribute = 'BINARY';
}
if ($unsigned) {
$attribute = 'UNSIGNED';
}
if ($zerofill) {
$attribute = 'UNSIGNED ZEROFILL';
}
$type = htmlspecialchars($extracted_fieldspec['print_type']);
$attribute = $extracted_fieldspec['attribute'];
if (! isset($row['Default'])) {
if ($row['Null'] != 'NO') {
$row['Default'] = '<i>NULL</i>';
@ -284,8 +262,7 @@ while ($row = PMA_DBI_fetch_row($rowset)) {
?>
</tr>
<?php
} // end while
PMA_DBI_free_result($result);
} // end foreach
$count++;
?>
</table>

View File

@ -359,7 +359,7 @@ if (!$is_information_schema) {
<?php echo PMA_generate_common_hidden_inputs($db); ?>
<fieldset>
<legend>
<?php echo PMA_getIcon('b_comment.png', __('Database comment: '), false, true); ?>
<?php echo PMA_getIcon('b_comment.png', __('Database comment: '), true); ?>
</legend>
<input type="text" name="comment" class="textfield" size="30"
value="<?php

View File

@ -105,7 +105,7 @@ if (0 == $tbl_result_cnt) {
// The tables list gets from MySQL
while (list($tbl) = PMA_DBI_fetch_row($tbl_result)) {
$fld_results = PMA_DBI_get_columns($db, $tbl, true);
$fld_results = PMA_DBI_get_columns($db, $tbl);
if (empty($tbl_names[$tbl]) && !empty($_REQUEST['TableList'])) {
$tbl_names[$tbl] = '';
@ -183,7 +183,7 @@ function showColumnSelectCell($columns, $column_number, $selected = '')
?>
<div id="visual_builder_anchor" class="notice hide">
<span id="footnote_1">
<?php echo __('Switch to') . ' <a href="' . $tab_designer['link'] . PMA_get_arg_separator('html') . 'query=1">' . __('visual builder') . '</a>'; ?>
<?php printf(__('Switch to %svisual builder%s'), ' <a href="' . $tab_designer['link'] . PMA_get_arg_separator('html') . 'query=1">', '</a>'); ?>
</span>
</div>
<?php

View File

@ -26,7 +26,7 @@ require_once './libraries/header_meta_style.inc.php';
if (isset($_GET['values'])) { // This page was displayed when the "add a new value" link or the link in tbl_alter.php was clicked
$values = explode(',', urldecode($_GET['values']));
} elseif (isset($_GET['num_fields'])) { // This page was displayed from submitting this form
for($field_num = 1; $field_num <= $_GET['num_fields']; $field_num++) {
for ($field_num = 1; $field_num <= $_GET['num_fields']; $field_num++) {
$values[] = "'" . str_replace(array("'", '\\'), array("''", '\\\\'), $_GET['field' . $field_num]) . "'";
}
}
@ -43,7 +43,7 @@ require_once './libraries/header_meta_style.inc.php';
// If extra empty fields are added, display them
if (isset($_GET['extra_fields'])) {
$total_fields += $_GET['extra_fields'];
for($i = $field_counter+1; $i <= $total_fields; $i++) {
for ($i = $field_counter+1; $i <= $total_fields; $i++) {
echo '<input type="text" size="30" name="field' . $i . '"/>';
}
} else {

View File

@ -347,25 +347,7 @@ if (!$save_on_server) {
// this was reported to happen under Plesk)
@ini_set('url_rewriter.tags','');
header('Content-Type: ' . $mime_type);
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
// Tested behavior of
// IE 5.50.4807.2300
// IE 6.0.2800.1106 (small glitch, asks twice when I click Open)
// IE 6.0.2900.2180
// Firefox 1.0.6
// in http and https
header('Content-Disposition: attachment; filename="' . $filename . '"');
if (PMA_USR_BROWSER_AGENT == 'IE') {
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
} else {
header('Pragma: no-cache');
// test case: exporting a database into a .gz file with Safari
// would produce files not having the current time
// (added this header for Safari but should not harm other browsers)
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
}
PMA_download_header($filename, $mime_type);
} else {
// HTML
if ($export_type == 'database') {

68
file_echo.php Normal file
View File

@ -0,0 +1,68 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* "Echo" service to allow force downloading of exported charts (png or svg)
* and server status monitor settings
*
* @package phpMyAdmin
*/
require_once './libraries/common.inc.php';
/* For chart exporting */
if (isset($_REQUEST['filename']) && isset($_REQUEST['image'])) {
$allowed = array(
'image/png' => 'png',
'image/svg+xml' => 'svg',
);
/* Check whether MIME type is allowed */
if (! isset($allowed[$_REQUEST['type']])) {
die('Invalid export type');
}
/*
* Check file name to match mime type and not contain new lines
* to prevent response splitting.
*/
$extension = $allowed[$_REQUEST['type']];
$valid_match = '/^[^\n\r]*\.' . $extension . '$/';
if (! preg_match($valid_match, $_REQUEST['filename'])) {
if (! preg_match('/^[^\n\r]*$/', $_REQUEST['filename'])) {
/* Filename is unsafe, discard it */
$filename = 'download.' . $extension;
} else {
/* Add extension */
$filename = $_REQUEST['filename'] . '.' . $extension;
}
} else {
/* Filename from request should be safe here */
$filename = $_REQUEST['filename'];
}
/* Decode data */
if ($extension != 'svg') {
$data = substr($_REQUEST['image'], strpos($_REQUEST['image'], ',') + 1);
$data = base64_decode($data);
} else {
$data = $_REQUEST['image'];
}
/* Send download header */
PMA_download_header($filename, $_REQUEST['type'], strlen($data));
/* Send data */
echo $data;
/* For monitor chart config export */
} else if (isset($_REQUEST['monitorconfig'])) {
PMA_download_header('monitor.cfg', 'application/force-download');
echo urldecode($_REQUEST['monitorconfig']);
/* For monitor chart config import */
} else if (isset($_REQUEST['import'])) {
header('Content-type: text/plain');
if(!file_exists($_FILES['file']['tmp_name'])) exit();
echo file_get_contents($_FILES['file']['tmp_name']);
}
?>

View File

@ -9,8 +9,7 @@ require_once './libraries/common.inc.php';
require_once './libraries/display_import_ajax.lib.php';
// AJAX requests can't be cached!
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 11 Jan 1991 06:30:00 GMT"); // Date in the past
PMA_no_cache_header();
// $GLOBALS["message"] is used for asking for an import message
if (isset($GLOBALS["message"]) && $GLOBALS["message"]) {

View File

@ -132,7 +132,7 @@ include ('./libraries/header_http.inc.php');
// ]]>
</script>
<?php
echo PMA_includeJS('jquery/jquery-1.6.1.js');
echo PMA_includeJS('jquery/jquery-1.6.2.js');
echo PMA_includeJS('update-location.js');
echo PMA_includeJS('common.js');
?>

View File

@ -19,7 +19,8 @@ var query_to_load = '';
*
* @param string db name
*/
function setDb(new_db) {
function setDb(new_db)
{
//alert('setDb(' + new_db + ')');
if (new_db != db) {
// db has changed
@ -51,7 +52,8 @@ function setDb(new_db) {
*
* @param string table name
*/
function setTable(new_table) {
function setTable(new_table)
{
//alert('setTable(' + new_table + ')');
if (new_table != table) {
// table has changed
@ -86,7 +88,8 @@ function setTable(new_table) {
* @uses encodeURIComponent()
* @param string url name of page to be loaded
*/
function refreshMain(url) {
function refreshMain(url)
{
if (! url) {
if (db) {
url = opendb_url;
@ -115,12 +118,13 @@ function refreshMain(url) {
* @uses lang
* @uses collation_connection
* @uses encodeURIComponent()
* @param boolean force force reloading
* @param boolean force force reloading
*/
function refreshNavigation(force) {
function refreshNavigation(force)
{
// The goTo() function won't refresh in case the target
// url is the same as the url given as parameter, but sometimes
// we want to refresh anyway.
// we want to refresh anyway.
if (typeof force != undefined && force && window.parent && window.parent.frame_navigation) {
window.parent.frame_navigation.location.reload();
} else {
@ -174,7 +178,8 @@ function markDbTable(db, table)
/**
* sets current selected server, table and db (called from libraries/footer.inc.php)
*/
function setAll( new_lang, new_collation_connection, new_server, new_db, new_table, new_token ) {
function setAll( new_lang, new_collation_connection, new_server, new_db, new_table, new_token )
{
//alert('setAll( ' + new_lang + ', ' + new_collation_connection + ', ' + new_server + ', ' + new_db + ', ' + new_table + ', ' + new_token + ' )');
if (new_server != server || new_lang != lang
|| new_collation_connection != collation_connection) {
@ -257,7 +262,8 @@ function focus_querywindow(sql_query)
* inserts query string into query window textarea
* called from script tag in querywindow
*/
function insertQuery() {
function insertQuery()
{
if (query_to_load != '' && querywindow.document && querywindow.document.getElementById && querywindow.document.getElementById('sqlquery')) {
querywindow.document.getElementById('sqlquery').value = query_to_load;
query_to_load = '';
@ -266,7 +272,8 @@ function insertQuery() {
return false;
}
function open_querywindow( url ) {
function open_querywindow( url )
{
if ( ! url ) {
url = 'querywindow.php?' + common_query + '&db=' + encodeURIComponent(db) + '&table=' + encodeURIComponent(table);
}
@ -293,7 +300,8 @@ function open_querywindow( url ) {
return true;
}
function refreshQuerywindow( url ) {
function refreshQuerywindow( url )
{
if ( ! querywindow.closed && querywindow.location ) {
if ( ! querywindow.document.sqlform.LockFromUpdate
@ -310,7 +318,8 @@ function refreshQuerywindow( url ) {
* @param string targeturl new url to load
* @param string target frame where to load the new url
*/
function goTo(targeturl, target) {
function goTo(targeturl, target)
{
//alert(targeturl);
if ( target == 'main' ) {
target = window.frame_content;
@ -339,7 +348,8 @@ function goTo(targeturl, target) {
}
// opens selected db in main frame
function openDb(new_db) {
function openDb(new_db)
{
//alert('opendb(' + new_db + ')');
setDb(new_db);
setTable('');
@ -347,7 +357,8 @@ function openDb(new_db) {
return true;
}
function updateTableTitle( table_link_id, new_title ) {
function updateTableTitle( table_link_id, new_title )
{
//alert('updateTableTitle');
if ( window.parent.frame_navigation.document && window.parent.frame_navigation.document.getElementById(table_link_id) ) {
var left = window.parent.frame_navigation.document;

View File

@ -14,7 +14,8 @@ var PMA_messages = {};
*
* @param {Element} field
*/
function getFieldType(field) {
function getFieldType(field)
{
field = $(field);
var tagName = field.prop('tagName');
if (tagName == 'INPUT') {
@ -40,7 +41,8 @@ function getFieldType(field) {
* @param {String} field_type see {@link #getFieldType}
* @param {String|Boolean} [value]
*/
function setFieldValue(field, field_type, value) {
function setFieldValue(field, field_type, value)
{
field = $(field);
switch (field_type) {
case 'text':
@ -78,7 +80,8 @@ function setFieldValue(field, field_type, value) {
* @param {String} field_type returned by {@link #getFieldType}
* @type Boolean|String|String[]
*/
function getFieldValue(field, field_type) {
function getFieldValue(field, field_type)
{
field = $(field);
switch (field_type) {
case 'text':
@ -101,7 +104,8 @@ function getFieldValue(field, field_type) {
/**
* Returns values for all fields in fieldsets
*/
function getAllValues() {
function getAllValues()
{
var elements = $('fieldset input, fieldset select, fieldset textarea');
var values = {};
var type, value;
@ -126,7 +130,8 @@ function getAllValues() {
* @param {String} type
* @return boolean
*/
function checkFieldDefault(field, type) {
function checkFieldDefault(field, type)
{
field = $(field);
var field_id = field.attr('id');
if (typeof defaultValues[field_id] == 'undefined') {
@ -157,7 +162,8 @@ function checkFieldDefault(field, type) {
* Returns element's id prefix
* @param {Element} element
*/
function getIdPrefix(element) {
function getIdPrefix(element)
{
return $(element).attr('id').replace(/[^-]+$/, '');
}
@ -254,7 +260,8 @@ var validators = {
* @param {boolean} onKeyUp whether fire on key up
* @param {Array} params validation function parameters
*/
function validateField(id, type, onKeyUp, params) {
function validateField(id, type, onKeyUp, params)
{
if (typeof validators[type] == 'undefined') {
return;
}
@ -272,7 +279,8 @@ function validateField(id, type, onKeyUp, params) {
* @type Array
* @return array of [function, paramseters to be passed to function]
*/
function getFieldValidators(field_id, onKeyUpOnly) {
function getFieldValidators(field_id, onKeyUpOnly)
{
// look for field bound validator
var name = field_id.match(/[^-]+$/)[0];
if (typeof validators._field[name] != 'undefined') {
@ -302,7 +310,8 @@ function getFieldValidators(field_id, onKeyUpOnly) {
*
* @param {Object} error_list list of errors in the form {field id: error array}
*/
function displayErrors(error_list) {
function displayErrors(error_list)
{
for (var field_id in error_list) {
var errors = error_list[field_id];
var field = $('#'+field_id);
@ -354,7 +363,8 @@ function displayErrors(error_list) {
* @param {boolean} isKeyUp
* @param {Object} errors
*/
function validate_fieldset(fieldset, isKeyUp, errors) {
function validate_fieldset(fieldset, isKeyUp, errors)
{
fieldset = $(fieldset);
if (fieldset.length && typeof validators._fieldset[fieldset.attr('id')] != 'undefined') {
var fieldset_errors = validators._fieldset[fieldset.attr('id')].apply(fieldset[0], [isKeyUp]);
@ -377,7 +387,8 @@ function validate_fieldset(fieldset, isKeyUp, errors) {
* @param {boolean} isKeyUp
* @param {Object} errors
*/
function validate_field(field, isKeyUp, errors) {
function validate_field(field, isKeyUp, errors)
{
field = $(field);
var field_id = field.attr('id');
errors[field_id] = [];
@ -403,7 +414,8 @@ function validate_field(field, isKeyUp, errors) {
* @param {Element} field
* @param {boolean} isKeyUp
*/
function validate_field_and_fieldset(field, isKeyUp) {
function validate_field_and_fieldset(field, isKeyUp)
{
field = $(field);
var errors = {};
validate_field(field, isKeyUp, errors);
@ -416,7 +428,8 @@ function validate_field_and_fieldset(field, isKeyUp) {
*
* @param {Element} field
*/
function markField(field) {
function markField(field)
{
field = $(field);
var type = getFieldType(field);
var isDefault = checkFieldDefault(field, type);
@ -433,7 +446,8 @@ function markField(field) {
* @param {Element} field
* @param {boolean} display
*/
function setRestoreDefaultBtn(field, display) {
function setRestoreDefaultBtn(field, display)
{
var el = $(field).closest('td').find('.restore-default img');
el[display ? 'show' : 'hide']();
}
@ -495,7 +509,8 @@ $(function() {
*
* @param {String} tab_id
*/
function setTab(tab_id) {
function setTab(tab_id)
{
$('.tabs a').removeClass('active').filter('[href=' + tab_id + ']').addClass('active');
$('.tabs_contents fieldset').hide().filter(tab_id).show();
location.hash = 'tab_' + tab_id.substr(1);
@ -562,7 +577,8 @@ $(function() {
*
* @param {String} field_id
*/
function restoreField(field_id) {
function restoreField(field_id)
{
var field = $('#'+field_id);
if (field.length == 0 || defaultValues[field_id] == undefined) {
return;

View File

@ -15,7 +15,8 @@
*/
/** Loads the database search results */
function loadResult(result_path , table_name , link , ajaxEnable){
function loadResult(result_path , table_name , link , ajaxEnable)
{
$(document).ready(function() {
if(ajaxEnable)
{
@ -43,7 +44,8 @@ function loadResult(result_path , table_name , link , ajaxEnable){
}
/** Delete the selected search results */
function deleteResult(result_path , msg , ajaxEnable){
function deleteResult(result_path , msg , ajaxEnable)
{
$(document).ready(function() {
/** Hides the results shown by the browse criteria */
$("#table-info").hide();

View File

@ -24,7 +24,8 @@
*
* @param jQuery object $this_anchor
*/
function PMA_adjustTotals($this_anchor) {
function PMA_adjustTotals($this_anchor)
{
var $parent_tr = $this_anchor.closest('tr');
var $rows_td = $parent_tr.find('.tbl_rows');
var $size_td = $parent_tr.find('.tbl_size');

View File

@ -3,7 +3,7 @@
* Functions used in the export tab
*
*/
/**
* Toggles the hiding and showing of each plugin's options
* according to the currently selected plugin from the dropdown list
@ -19,7 +19,7 @@
});
/**
* Toggles the enabling and disabling of the SQL plugin's comment options that apply only when exporting structure
* Toggles the enabling and disabling of the SQL plugin's comment options that apply only when exporting structure
*/
$(document).ready(function() {
$("input[type='radio'][name$='sql_structure_or_data']").change(function() {
@ -50,7 +50,8 @@ $(document).ready(function() {
* options
*/
function toggle_structure_data_opts(pluginName) {
function toggle_structure_data_opts(pluginName)
{
var radioFormName = pluginName + "_structure_or_data";
var dataDiv = "#" + pluginName + "_data";
var structureDiv = "#" + pluginName + "_structure";
@ -89,7 +90,8 @@ $(document).ready(function() {
/**
* Toggles the disabling of the "save to file" options
*/
function toggle_save_to_file() {
function toggle_save_to_file()
{
if($("#radio_dump_asfile:checked").length == 0) {
$("#ul_save_asfile > li").fadeTo('fast', 0.4);
$("#ul_save_asfile > li > input").attr('disabled', 'disabled');
@ -111,7 +113,8 @@ $(document).ready(function() {
/**
* For SQL plugin, toggles the disabling of the "display comments" options
*/
function toggle_sql_include_comments() {
function toggle_sql_include_comments()
{
$("#checkbox_sql_include_comments").change(function() {
if($("#checkbox_sql_include_comments:checked").length == 0) {
$("#ul_include_comments > li").fadeTo('fast', 0.4);
@ -130,8 +133,8 @@ function toggle_sql_include_comments() {
}
/**
* For SQL plugin, if "CREATE TABLE options" is checked/unchecked, check/uncheck each of its sub-options
*/
* For SQL plugin, if "CREATE TABLE options" is checked/unchecked, check/uncheck each of its sub-options
*/
$(document).ready(function() {
$("#checkbox_sql_create_table_statements").change(function() {
if($("#checkbox_sql_create_table_statements:checked").length == 0) {
@ -144,7 +147,7 @@ $(document).ready(function() {
});
});
/**
/**
* Disables the view output as text option if the output must be saved as a file
*/
$(document).ready(function() {
@ -164,7 +167,8 @@ $(document).ready(function() {
/**
* Toggles display of options when quick and custom export are selected
*/
function toggle_quick_or_custom() {
function toggle_quick_or_custom()
{
if($("$(this):checked").attr("value") == "custom") {
$("#databases_and_tables").show();
$("#rows").show();
@ -222,4 +226,4 @@ $(document).ready(function() {
$("input[type='text'][name='limit_from']").removeAttr('disabled');
}
});
});
});

View File

@ -29,14 +29,14 @@ var codemirror_editor = false;
*/
var chart_activeTimeouts = new Object();
/**
* Add a hidden field to the form to indicate that this will be an
* Ajax request (only if this hidden field does not exist)
*
* @param object the form
*/
function PMA_prepareForAjaxRequest($form) {
function PMA_prepareForAjaxRequest($form)
{
if (! $form.find('input:hidden').is('#ajax_request_hidden')) {
$form.append('<input type="hidden" id="ajax_request_hidden" name="ajax_request" value="true" />');
}
@ -49,7 +49,8 @@ function PMA_prepareForAjaxRequest($form) {
*
* @return boolean always true
*/
function suggestPassword(passwd_form) {
function suggestPassword(passwd_form)
{
// restrict the password to just letters and numbers to avoid problems:
// "editors and viewers regard the password as multiple words and
// things like double click no longer work"
@ -69,7 +70,8 @@ function suggestPassword(passwd_form) {
/**
* Version string to integer conversion.
*/
function parseVersionString (str) {
function parseVersionString (str)
{
if (typeof(str) != 'string') { return false; }
var add = 0;
// Parse possible alpha/beta/rc/
@ -99,7 +101,8 @@ function parseVersionString (str) {
/**
* Indicates current available version on main page.
*/
function PMA_current_version() {
function PMA_current_version()
{
var current = parseVersionString(pmaversion);
var latest = parseVersionString(PMA_latest_version);
var version_information_message = PMA_messages['strLatestAvailable'] + ' ' + PMA_latest_version;
@ -125,7 +128,8 @@ function PMA_current_version() {
*
*/
function displayPasswordGenerateButton() {
function displayPasswordGenerateButton()
{
$('#tr_element_before_generate_password').parent().append('<tr><td>' + PMA_messages['strGeneratePassword'] + '</td><td><input type="button" id="button_generate_password" value="' + PMA_messages['strGenerate'] + '" onclick="suggestPassword(this.form)" /><input type="text" name="generated_pw" id="generated_pw" /></td></tr>');
$('#div_element_before_generate_password').parent().append('<div class="item"><label for="button_generate_password">' + PMA_messages['strGeneratePassword'] + ':</label><span class="options"><input type="button" id="button_generate_password" value="' + PMA_messages['strGenerate'] + '" onclick="suggestPassword(this.form)" /></span><input type="text" name="generated_pw" id="generated_pw" /></div>');
}
@ -135,7 +139,8 @@ function displayPasswordGenerateButton() {
*
* @param object $this_element a jQuery object pointing to the element
*/
function PMA_addDatepicker($this_element, options) {
function PMA_addDatepicker($this_element, options)
{
var showTimeOption = false;
if ($this_element.is('.datetimefield')) {
showTimeOption = true;
@ -177,7 +182,8 @@ function PMA_addDatepicker($this_element, options) {
* @param boolean only_once if true this is only done once
* f.e. only on first focus
*/
function selectContent( element, lock, only_once ) {
function selectContent( element, lock, only_once )
{
if ( only_once && only_once_elements[element.name] ) {
return;
}
@ -721,7 +727,8 @@ var marked_row = new Array;
*
* @param container DOM element
*/
function markAllRows( container_id ) {
function markAllRows( container_id )
{
$("#"+container_id).find("input:checkbox:enabled").attr('checked', 'checked')
.parents("tr").addClass("marked");
@ -734,7 +741,8 @@ function markAllRows( container_id ) {
*
* @param container DOM element
*/
function unMarkAllRows( container_id ) {
function unMarkAllRows( container_id )
{
$("#"+container_id).find("input:checkbox:enabled").removeAttr('checked')
.parents("tr").removeClass("marked");
@ -748,7 +756,8 @@ function unMarkAllRows( container_id ) {
* @param boolean state new value for checkbox (true or false)
* @return boolean always true
*/
function setCheckboxes( container_id, state ) {
function setCheckboxes( container_id, state )
{
if(state) {
$("#"+container_id).find("input:checkbox").attr('checked', 'checked');
@ -778,7 +787,8 @@ function setSelectOptions(the_form, the_select, do_check)
/**
* Sets current value for query box.
*/
function setQuery(query) {
function setQuery(query)
{
if (codemirror_editor) {
codemirror_editor.setValue(query);
} else {
@ -791,7 +801,8 @@ function setQuery(query) {
* Create quick sql statements.
*
*/
function insertQuery(queryType) {
function insertQuery(queryType)
{
if (queryType == "clear") {
setQuery('');
return;
@ -840,7 +851,8 @@ function insertQuery(queryType) {
* Inserts multiple fields.
*
*/
function insertValueQuery() {
function insertValueQuery()
{
var myQuery = document.sqlform.sql_query;
var myListBox = document.sqlform.dummy;
@ -885,14 +897,16 @@ function insertValueQuery() {
/**
* listbox redirection
*/
function goToUrl(selObj, goToLocation) {
function goToUrl(selObj, goToLocation)
{
eval("document.location.href = '" + goToLocation + "pos=" + selObj.options[selObj.selectedIndex].value + "'");
}
/**
* getElement
*/
function getElement(e,f){
function getElement(e,f)
{
if(document.layers){
f=(f)?f:self;
if(f.document.layers[e]) {
@ -911,7 +925,8 @@ function getElement(e,f){
/**
* Refresh the WYSIWYG scratchboard after changes have been made
*/
function refreshDragOption(e) {
function refreshDragOption(e)
{
var elm = $('#' + e);
if (elm.css('visibility') == 'visible') {
refreshLayout();
@ -922,7 +937,8 @@ function refreshDragOption(e) {
/**
* Refresh/resize the WYSIWYG scratchboard
*/
function refreshLayout() {
function refreshLayout()
{
var elm = $('#pdflayout')
var orientation = $('#orientation_opt').val();
if($('#paper_opt').length==1){
@ -944,7 +960,8 @@ function refreshLayout() {
/**
* Show/hide the WYSIWYG scratchboard
*/
function ToggleDragDrop(e) {
function ToggleDragDrop(e)
{
var elm = $('#' + e);
if (elm.css('visibility') == 'hidden') {
PDFinit(); /* Defined in pdf_pages.php */
@ -962,7 +979,8 @@ function ToggleDragDrop(e) {
* PDF scratchboard: When a position is entered manually, update
* the fields inside the scratchboard.
*/
function dragPlace(no, axis, value) {
function dragPlace(no, axis, value)
{
var elm = $('#table_' + no);
if (axis == 'x') {
elm.css('left', value + 'px');
@ -974,7 +992,8 @@ function dragPlace(no, axis, value) {
/**
* Returns paper sizes for a given format
*/
function pdfPaperSize(format, axis) {
function pdfPaperSize(format, axis)
{
switch (format.toUpperCase()) {
case '4A0':
if (axis == 'x') return 4767.87; else return 6740.79;
@ -1302,7 +1321,8 @@ $(document).ready(function(){
* optional, defaults to 5000
* @return jQuery object jQuery Element that holds the message div
*/
function PMA_ajaxShowMessage(message, timeout) {
function PMA_ajaxShowMessage(message, timeout)
{
//Handle the case when a empty data.message is passed. We don't want the empty message
if (message == '') {
@ -1352,7 +1372,8 @@ function PMA_ajaxShowMessage(message, timeout) {
/**
* Removes the message shown for an Ajax operation when it's completed
*/
function PMA_ajaxRemoveMessage($this_msgbox) {
function PMA_ajaxRemoveMessage($this_msgbox)
{
if ($this_msgbox != undefined && $this_msgbox instanceof jQuery) {
$this_msgbox
.stop(true, true)
@ -1363,7 +1384,8 @@ function PMA_ajaxRemoveMessage($this_msgbox) {
/**
* Hides/shows the "Open in ENUM/SET editor" message, depending on the data type of the column currently selected
*/
function PMA_showNoticeForEnum(selectElement) {
function PMA_showNoticeForEnum(selectElement)
{
var enum_notice_id = selectElement.attr("id").split("_")[1];
enum_notice_id += "_" + (parseInt(selectElement.attr("id").split("_")[2]) + 1);
var selectedType = selectElement.attr("value");
@ -1377,7 +1399,8 @@ function PMA_showNoticeForEnum(selectElement) {
/**
* Generates a dialog box to pop up the create_table form
*/
function PMA_createTableDialog( div, url , target) {
function PMA_createTableDialog( div, url , target)
{
/**
* @var button_options Object that stores the options passed to jQueryUI
* dialog
@ -1440,7 +1463,8 @@ function PMA_createTableDialog( div, url , target) {
*
* @return object The created highcharts instance
*/
function PMA_createChart(passedSettings) {
function PMA_createChart(passedSettings)
{
var container = passedSettings.chart.renderTo;
var settings = {
@ -1575,7 +1599,8 @@ function PMA_createChart(passedSettings) {
/*
* Creates a Profiling Chart. Used in sql.php and server_status.js
*/
function PMA_createProfilingChart(data, options) {
function PMA_createProfilingChart(data, options)
{
return PMA_createChart($.extend(true, {
chart: {
renderTo: 'profilingchart',
@ -1609,15 +1634,18 @@ function PMA_createProfilingChart(data, options) {
}
// Formats a profiling duration nicely. Used in PMA_createProfilingChart() and server_status.js
function PMA_prettyProfilingNum(num, acc) {
function PMA_prettyProfilingNum(num, acc)
{
if (!acc) {
acc = 1;
acc = 2;
}
acc = Math.pow(10,acc);
if (num*1000 < 0.1) {
num = Math.round(acc*(num*1000*1000))/acc + 'µ'
if (num * 1000 < 0.1) {
num = Math.round(acc * (num * 1000 * 1000)) / acc + 'µ';
} else if (num < 0.1) {
num = Math.round(acc*(num*1000))/acc + 'm'
num = Math.round(acc * (num * 1000)) / acc + 'm';
} else {
num = Math.round(acc * num) / acc;
}
return num + 's';
@ -2018,7 +2046,7 @@ $(document).ready(function() {
$("#result_query .notice").remove();
$("#result_query").prepend((data.message));
$("#copyTable").find("select[name='target_db'] option[value="+data.db+"]").attr('selected', 'selected');
//Refresh navigation frame when the table is coppied
if (window.parent && window.parent.frame_navigation) {
window.parent.frame_navigation.location.reload();
@ -2202,7 +2230,8 @@ $(document).ready(function() {
});
});
function PMA_verifyTypeOfAllColumns() {
function PMA_verifyTypeOfAllColumns()
{
$("select[class='column_type']").each(function() {
PMA_showNoticeForEnum($(this));
});
@ -2211,7 +2240,8 @@ function PMA_verifyTypeOfAllColumns() {
/**
* Closes the ENUM/SET editor and removes the data in it
*/
function disable_popup() {
function disable_popup()
{
$("#popup_background").fadeOut("fast");
$("#enum_editor").fadeOut("fast");
// clear the data from the text boxes
@ -2307,7 +2337,8 @@ $(document).ready(function() {
displayMoreTableOpts();
});
function displayMoreTableOpts() {
function displayMoreTableOpts()
{
// Remove the actions from the table cells (they are available by default for JavaScript-disabled browsers)
// if the table is not a view or information_schema (otherwise there is only one action to hide and there's no point)
if($("input[type='hidden'][name='table_type']").val() == "table") {
@ -2424,7 +2455,8 @@ function checkIndexName(form_id)
* ommit this parameter the function searches
* the footnotes in the whole body
**/
function PMA_convertFootnotesToTooltips($div) {
function PMA_convertFootnotesToTooltips($div)
{
// Hide the footnotes from the footer (which are displayed for
// JavaScript-disabled browsers) since the tooltip is sufficient
@ -2570,14 +2602,16 @@ $(function() {
/**
* Get the row number from the classlist (for example, row_1)
*/
function PMA_getRowNumber(classlist) {
function PMA_getRowNumber(classlist)
{
return parseInt(classlist.split(/\s+row_/)[1]);
}
/**
* Changes status of slider
*/
function PMA_set_status_label(id) {
function PMA_set_status_label(id)
{
if ($('#' + id).css('display') == 'none') {
$('#anchor_status_' + id).text('+ ');
} else {
@ -2588,7 +2622,8 @@ function PMA_set_status_label(id) {
/**
* Initializes slider effect.
*/
function PMA_init_slider() {
function PMA_init_slider()
{
$('.pma_auto_slider').each(function(idx, e) {
if ($(e).hasClass('slider_init_done')) return;
$(e).addClass('slider_init_done');
@ -2869,7 +2904,8 @@ $(document).ready(function() {
*
* @return bool True on success, false on failure
*/
function PMA_slidingMessage(msg, $obj) {
function PMA_slidingMessage(msg, $obj)
{
if (msg == undefined || msg.length == 0) {
// Don't show an empty message
return false;
@ -3040,7 +3076,8 @@ $(document).ready(function() {
* Create default PMA tooltip for the element specified. The default appearance
* can be overriden by specifying optional "options" parameter (see qTip options).
*/
function PMA_createqTip($elements, content, options) {
function PMA_createqTip($elements, content, options)
{
var o = {
content: content,
style: {

View File

@ -5,6 +5,9 @@
* (c) 2010 Torstein Hønsi
*
* License: www.highcharts.com/license
*
* Please Note: This file has been adjusted for use in phpMyAdmin,
* to allow chart exporting without the batik library
*/
// JSLint options:
@ -104,7 +107,7 @@ defaultOptions.exporting = {
//enabled: true,
//filename: 'chart',
type: 'image/png',
url: 'chart_export.php',
url: 'file_echo.php',
width: 800,
buttons: {
exportButton: {

View File

@ -9,10 +9,11 @@
* Toggles the hiding and showing of each plugin's options
* according to the currently selected plugin from the dropdown list
*/
function changePluginOpts() {
$(".format_specific_options").each(function() {
function changePluginOpts()
{
$(".format_specific_options").each(function() {
$(this).hide();
});
});
var selected_plugin_name = $("#plugins option:selected").attr("value");
$("#" + selected_plugin_name + "_options").fadeIn('slow');
if(selected_plugin_name == "csv") {
@ -26,7 +27,8 @@ function changePluginOpts() {
* Toggles the hiding and showing of each plugin's options and sets the selected value
* in the plugin dropdown list according to the format of the selected file
*/
function matchFile(fname) {
function matchFile(fname)
{
var fname_array = fname.toLowerCase().split(".");
var len = fname_array.length;
if(len != 0) {
@ -43,7 +45,7 @@ function matchFile(fname) {
}
}
$(document).ready(function() {
// Initially display the options for the selected plugin
// Initially display the options for the selected plugin
changePluginOpts();
// Whenever the selected plugin changes, change the options displayed
@ -79,4 +81,4 @@ $(document).ready(function() {
$("#scroll_to_options_msg").hide();
$(".format_specific_options").css({ "border": 0, "margin": 0, "padding": 0 });
$(".format_specific_options h3").remove();
});
});

View File

@ -1,5 +1,5 @@
/*!
* jQuery JavaScript Library v1.6.1
* jQuery JavaScript Library v1.6.2
* http://jquery.com/
*
* Copyright 2011, John Resig
@ -11,7 +11,7 @@
* Copyright 2011, The Dojo Foundation
* Released under the MIT, BSD, and GPL Licenses.
*
* Date: Thu May 12 15:04:36 2011 -0400
* Date: Thu Jun 30 14:16:56 2011 -0400
*/
(function( window, undefined ) {
@ -65,6 +65,14 @@ var jQuery = function( selector, context ) {
rmsie = /(msie) ([\w.]+)/,
rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
// Matches dashed string for camelizing
rdashAlpha = /-([a-z])/ig,
// Used by jQuery.camelCase as callback to replace()
fcamelCase = function( all, letter ) {
return letter.toUpperCase();
},
// Keep a UserAgent string for use with jQuery.browser
userAgent = navigator.userAgent,
@ -204,7 +212,7 @@ jQuery.fn = jQuery.prototype = {
selector: "",
// The current version of jQuery being used
jquery: "1.6.1",
jquery: "1.6.2",
// The default length of a jQuery object is 0
length: 0,
@ -603,6 +611,12 @@ jQuery.extend({
}
},
// Converts a dashed string to camelCased string;
// Used by both the css and data modules
camelCase: function( string ) {
return string.replace( rdashAlpha, fcamelCase );
},
nodeName: function( elem, name ) {
return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
},
@ -799,7 +813,7 @@ jQuery.extend({
},
// Mutifunctional method to get and set values to a collection
// The value/s can be optionally by executed if its a function
// The value/s can optionally be executed if it's a function
access: function( elems, key, value, exec, fn, pass ) {
var length = elems.length;
@ -930,7 +944,6 @@ function doScrollCheck() {
jQuery.ready();
}
// Expose jQuery to the global object
return jQuery;
})();
@ -1147,7 +1160,9 @@ jQuery.support = (function() {
support,
fragment,
body,
bodyStyle,
testElementParent,
testElement,
testElementStyle,
tds,
events,
eventName,
@ -1241,11 +1256,10 @@ jQuery.support = (function() {
}
if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
div.attachEvent( "onclick", function click() {
div.attachEvent( "onclick", function() {
// Cloning a node shouldn't copy over any
// bound event handlers (IE does this)
support.noCloneEvent = false;
div.detachEvent( "onclick", click );
});
div.cloneNode( true ).fireEvent( "onclick" );
}
@ -1270,22 +1284,30 @@ jQuery.support = (function() {
// Figure out if the W3C box model works as expected
div.style.width = div.style.paddingLeft = "1px";
// We use our own, invisible, body
body = document.createElement( "body" );
bodyStyle = {
body = document.getElementsByTagName( "body" )[ 0 ];
// We use our own, invisible, body unless the body is already present
// in which case we use a div (#9239)
testElement = document.createElement( body ? "div" : "body" );
testElementStyle = {
visibility: "hidden",
width: 0,
height: 0,
border: 0,
margin: 0,
// Set background to avoid IE crashes when removing (#9028)
background: "none"
margin: 0
};
for ( i in bodyStyle ) {
body.style[ i ] = bodyStyle[ i ];
if ( body ) {
jQuery.extend( testElementStyle, {
position: "absolute",
left: -1000,
top: -1000
});
}
body.appendChild( div );
documentElement.insertBefore( body, documentElement.firstChild );
for ( i in testElementStyle ) {
testElement.style[ i ] = testElementStyle[ i ];
}
testElement.appendChild( div );
testElementParent = body || documentElement;
testElementParent.insertBefore( testElement, testElementParent.firstChild );
// Check if a disconnected checkbox will retain its checked
// value of true after appended to the DOM (IE6/7)
@ -1344,8 +1366,8 @@ jQuery.support = (function() {
}
// Remove the body element we added
body.innerHTML = "";
documentElement.removeChild( body );
testElement.innerHTML = "";
testElementParent.removeChild( testElement );
// Technique from Juriy Zaytsev
// http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
@ -1369,6 +1391,9 @@ jQuery.support = (function() {
}
}
// Null connected elements to avoid leaks in IE
testElement = fragment = select = opt = body = marginDiv = div = input = null;
return support;
})();
@ -1486,7 +1511,10 @@ jQuery.extend({
return thisCache[ internalKey ] && thisCache[ internalKey ].events;
}
return getByName ? thisCache[ jQuery.camelCase( name ) ] : thisCache;
return getByName ?
// Check for both converted-to-camel and non-converted data property names
thisCache[ jQuery.camelCase( name ) ] || thisCache[ name ] :
thisCache;
},
removeData: function( elem, name, pvt /* Internal Use Only */ ) {
@ -1882,7 +1910,7 @@ var rclass = /[\n\t\r]/g,
rfocusable = /^(?:button|input|object|select|textarea)$/i,
rclickable = /^a(?:rea)?$/i,
rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
rinvalidChar = /\:/,
rinvalidChar = /\:|^on/,
formHook, boolHook;
jQuery.fn.extend({
@ -1912,30 +1940,31 @@ jQuery.fn.extend({
},
addClass: function( value ) {
var classNames, i, l, elem,
setClass, c, cl;
if ( jQuery.isFunction( value ) ) {
return this.each(function(i) {
var self = jQuery(this);
self.addClass( value.call(this, i, self.attr("class") || "") );
return this.each(function( j ) {
jQuery( this ).addClass( value.call(this, j, this.className) );
});
}
if ( value && typeof value === "string" ) {
var classNames = (value || "").split( rspace );
classNames = value.split( rspace );
for ( var i = 0, l = this.length; i < l; i++ ) {
var elem = this[i];
for ( i = 0, l = this.length; i < l; i++ ) {
elem = this[ i ];
if ( elem.nodeType === 1 ) {
if ( !elem.className ) {
if ( !elem.className && classNames.length === 1 ) {
elem.className = value;
} else {
var className = " " + elem.className + " ",
setClass = elem.className;
setClass = " " + elem.className + " ";
for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) {
setClass += " " + classNames[c];
for ( c = 0, cl = classNames.length; c < cl; c++ ) {
if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) {
setClass += classNames[ c ] + " ";
}
}
elem.className = jQuery.trim( setClass );
@ -1948,24 +1977,25 @@ jQuery.fn.extend({
},
removeClass: function( value ) {
if ( jQuery.isFunction(value) ) {
return this.each(function(i) {
var self = jQuery(this);
self.removeClass( value.call(this, i, self.attr("class")) );
var classNames, i, l, elem, className, c, cl;
if ( jQuery.isFunction( value ) ) {
return this.each(function( j ) {
jQuery( this ).removeClass( value.call(this, j, this.className) );
});
}
if ( (value && typeof value === "string") || value === undefined ) {
var classNames = (value || "").split( rspace );
classNames = (value || "").split( rspace );
for ( var i = 0, l = this.length; i < l; i++ ) {
var elem = this[i];
for ( i = 0, l = this.length; i < l; i++ ) {
elem = this[ i ];
if ( elem.nodeType === 1 && elem.className ) {
if ( value ) {
var className = (" " + elem.className + " ").replace(rclass, " ");
for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
className = className.replace(" " + classNames[c] + " ", " ");
className = (" " + elem.className + " ").replace( rclass, " " );
for ( c = 0, cl = classNames.length; c < cl; c++ ) {
className = className.replace(" " + classNames[ c ] + " ", " ");
}
elem.className = jQuery.trim( className );
@ -1984,9 +2014,8 @@ jQuery.fn.extend({
isBool = typeof stateVal === "boolean";
if ( jQuery.isFunction( value ) ) {
return this.each(function(i) {
var self = jQuery(this);
self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal );
return this.each(function( i ) {
jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
});
}
@ -2040,7 +2069,13 @@ jQuery.fn.extend({
return ret;
}
return (elem.value || "").replace(rreturn, "");
ret = elem.value;
return typeof ret === "string" ?
// handle most common string cases
ret.replace(rreturn, "") :
// handle cases where value is null/undef or number
ret == null ? "" : ret;
}
return undefined;
@ -2186,20 +2221,23 @@ jQuery.extend({
notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
// Normalize the name if needed
name = notxml && jQuery.attrFix[ name ] || name;
if ( notxml ) {
name = jQuery.attrFix[ name ] || name;
hooks = jQuery.attrHooks[ name ];
hooks = jQuery.attrHooks[ name ];
if ( !hooks ) {
// Use boolHook for boolean attributes
if ( rboolean.test( name ) &&
(typeof value === "boolean" || value === undefined || value.toLowerCase() === name.toLowerCase()) ) {
if ( !hooks ) {
// Use boolHook for boolean attributes
if ( rboolean.test( name ) ) {
hooks = boolHook;
hooks = boolHook;
// Use formHook for forms and if the name contains certain characters
} else if ( formHook && (jQuery.nodeName( elem, "form" ) || rinvalidChar.test( name )) ) {
hooks = formHook;
// Use formHook for forms and if the name contains certain characters
} else if ( formHook && name !== "className" &&
(jQuery.nodeName( elem, "form" ) || rinvalidChar.test( name )) ) {
hooks = formHook;
}
}
}
@ -2217,8 +2255,8 @@ jQuery.extend({
return value;
}
} else if ( hooks && "get" in hooks && notxml ) {
return hooks.get( elem, name );
} else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) {
return ret;
} else {
@ -2282,6 +2320,25 @@ jQuery.extend({
0 :
undefined;
}
},
// Use the value property for back compat
// Use the formHook for button elements in IE6/7 (#1954)
value: {
get: function( elem, name ) {
if ( formHook && jQuery.nodeName( elem, "button" ) ) {
return formHook.get( elem, name );
}
return name in elem ?
elem.value :
null;
},
set: function( elem, value, name ) {
if ( formHook && jQuery.nodeName( elem, "button" ) ) {
return formHook.set( elem, value, name );
}
// Does not return so that setAttribute is also used
elem.value = value;
}
}
},
@ -2311,10 +2368,11 @@ jQuery.extend({
var ret, hooks,
notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
// Try to normalize/fix the name
name = notxml && jQuery.propFix[ name ] || name;
hooks = jQuery.propHooks[ name ];
if ( notxml ) {
// Fix name and attach hooks
name = jQuery.propFix[ name ] || name;
hooks = jQuery.propHooks[ name ];
}
if ( value !== undefined ) {
if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
@ -2341,7 +2399,7 @@ jQuery.extend({
boolHook = {
get: function( elem, name ) {
// Align boolean attributes with corresponding properties
return elem[ jQuery.propFix[ name ] || name ] ?
return jQuery.prop( elem, name ) ?
name.toLowerCase() :
undefined;
},
@ -2356,7 +2414,7 @@ boolHook = {
propName = jQuery.propFix[ name ] || name;
if ( propName in elem ) {
// Only set the IDL specifically if it already exists on the element
elem[ propName ] = value;
elem[ propName ] = true;
}
elem.setAttribute( name, name.toLowerCase() );
@ -2365,24 +2423,6 @@ boolHook = {
}
};
// Use the value property for back compat
// Use the formHook for button elements in IE6/7 (#1954)
jQuery.attrHooks.value = {
get: function( elem, name ) {
if ( formHook && jQuery.nodeName( elem, "button" ) ) {
return formHook.get( elem, name );
}
return elem.value;
},
set: function( elem, value, name ) {
if ( formHook && jQuery.nodeName( elem, "button" ) ) {
return formHook.set( elem, value, name );
}
// Does not return so that setAttribute is also used
elem.value = value;
}
};
// IE6/7 do not support getting/setting some attributes with get/setAttribute
if ( !jQuery.support.getSetAttribute ) {
@ -2390,7 +2430,7 @@ if ( !jQuery.support.getSetAttribute ) {
jQuery.attrFix = jQuery.propFix;
// Use this for any attribute on a form in IE6/7
formHook = jQuery.attrHooks.name = jQuery.valHooks.button = {
formHook = jQuery.attrHooks.name = jQuery.attrHooks.title = jQuery.valHooks.button = {
get: function( elem, name ) {
var ret;
ret = elem.getAttributeNode( name );
@ -2493,8 +2533,7 @@ jQuery.each([ "radio", "checkbox" ], function() {
var hasOwn = Object.prototype.hasOwnProperty,
rnamespaces = /\.(.*)$/,
var rnamespaces = /\.(.*)$/,
rformElems = /^(?:textarea|input|select)$/i,
rperiod = /\./g,
rspaces = / /g,
@ -2838,7 +2877,7 @@ jQuery.event = {
event.target = elem;
// Clone any incoming data and prepend the event, creating the handler arg list
data = data ? jQuery.makeArray( data ) : [];
data = data != null ? jQuery.makeArray( data ) : [];
data.unshift( event );
var cur = elem,
@ -3144,34 +3183,27 @@ jQuery.Event.prototype = {
// Checks if an event happened on an element within another element
// Used in jQuery.event.special.mouseenter and mouseleave handlers
var withinElement = function( event ) {
// Check if mouse(over|out) are still within the same parent element
var parent = event.relatedTarget;
// set the correct event type
// Check if mouse(over|out) are still within the same parent element
var related = event.relatedTarget,
inside = false,
eventType = event.type;
event.type = event.data;
// Firefox sometimes assigns relatedTarget a XUL element
// which we cannot access the parentNode property of
try {
if ( related !== this ) {
// Chrome does something similar, the parentNode property
// can be accessed but is null.
if ( parent && parent !== document && !parent.parentNode ) {
return;
if ( related ) {
inside = jQuery.contains( this, related );
}
// Traverse up the tree
while ( parent && parent !== this ) {
parent = parent.parentNode;
}
if ( !inside ) {
if ( parent !== this ) {
// handle event if we actually just moused on to a non sub-element
jQuery.event.handle.apply( this, arguments );
}
// assuming we've left the element since we most likely mousedover a xul element
} catch(e) { }
event.type = eventType;
}
}
},
// In case of event delegation, we only need to rename the event.type,
@ -5890,8 +5922,21 @@ function cloneFixAttributes( src, dest ) {
}
jQuery.buildFragment = function( args, nodes, scripts ) {
var fragment, cacheable, cacheresults,
doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document);
var fragment, cacheable, cacheresults, doc;
// nodes may contain either an explicit document object,
// a jQuery collection or context object.
// If nodes[0] contains a valid object to assign to doc
if ( nodes && nodes[0] ) {
doc = nodes[0].ownerDocument || nodes[0];
}
// Ensure that an attr object doesn't incorrectly stand in as a document object
// Chrome and Firefox seem to allow this to occur and will throw exception
// Fixes #8950
if ( !doc.createDocumentFragment ) {
doc = document;
}
// Only cache "small" (1/2 KB) HTML strings that are associated with the main document
// Cloning options loses the selected state, so don't cache them
@ -5972,7 +6017,7 @@ function fixDefaultChecked( elem ) {
function findInputs( elem ) {
if ( jQuery.nodeName( elem, "input" ) ) {
fixDefaultChecked( elem );
} else if ( elem.getElementsByTagName ) {
} else if ( "getElementsByTagName" in elem ) {
jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked );
}
}
@ -6021,6 +6066,8 @@ jQuery.extend({
}
}
srcElements = destElements = null;
// Return the cloned set
return clone;
},
@ -6201,10 +6248,8 @@ function evalScript( i, elem ) {
var ralpha = /alpha\([^)]*\)/i,
ropacity = /opacity=([^)]*)/,
rdashAlpha = /-([a-z])/ig,
// fixed for IE9, see #8346
rupper = /([A-Z]|^ms)/g,
rnumpx = /^-?\d+(?:px)?$/i,
@ -6218,11 +6263,7 @@ var ralpha = /alpha\([^)]*\)/i,
curCSS,
getComputedStyle,
currentStyle,
fcamelCase = function( all, letter ) {
return letter.toUpperCase();
};
currentStyle;
jQuery.fn.css = function( name, value ) {
// Setting 'undefined' is a no-op
@ -6257,13 +6298,14 @@ jQuery.extend({
// Exclude the following css properties to add px
cssNumber: {
"zIndex": true,
"fillOpacity": true,
"fontWeight": true,
"opacity": true,
"zoom": true,
"lineHeight": true,
"opacity": true,
"orphans": true,
"widows": true,
"orphans": true
"zIndex": true,
"zoom": true
},
// Add in properties whose names you wish to fix before
@ -6298,6 +6340,8 @@ jQuery.extend({
// convert relative number strings (+= or -=) to relative numbers. #7345
if ( type === "string" && rrelNum.test( value ) ) {
value = +value.replace( rrelNumFilter, "" ) + parseFloat( jQuery.css( elem, name ) );
// Fixes bug #9237
type = "number";
}
// If a number was passed in, add 'px' to the (except for certain CSS properties)
@ -6364,10 +6408,6 @@ jQuery.extend({
for ( name in options ) {
elem.style[ name ] = old[ name ];
}
},
camelCase: function( string ) {
return string.replace( rdashAlpha, fcamelCase );
}
});
@ -6381,44 +6421,21 @@ jQuery.each(["height", "width"], function( i, name ) {
if ( computed ) {
if ( elem.offsetWidth !== 0 ) {
val = getWH( elem, name, extra );
return getWH( elem, name, extra );
} else {
jQuery.swap( elem, cssShow, function() {
val = getWH( elem, name, extra );
});
}
if ( val <= 0 ) {
val = curCSS( elem, name, name );
if ( val === "0px" && currentStyle ) {
val = currentStyle( elem, name, name );
}
if ( val != null ) {
// Should return "auto" instead of 0, use 0 for
// temporary backwards-compat
return val === "" || val === "auto" ? "0px" : val;
}
}
if ( val < 0 || val == null ) {
val = elem.style[ name ];
// Should return "auto" instead of 0, use 0 for
// temporary backwards-compat
return val === "" || val === "auto" ? "0px" : val;
}
return typeof val === "string" ? val : val + "px";
return val;
}
},
set: function( elem, value ) {
if ( rnumpx.test( value ) ) {
// ignore negative width and height values #1599
value = parseFloat(value);
value = parseFloat( value );
if ( value >= 0 ) {
return value + "px";
@ -6541,27 +6558,50 @@ if ( document.documentElement.currentStyle ) {
curCSS = getComputedStyle || currentStyle;
function getWH( elem, name, extra ) {
var which = name === "width" ? cssWidth : cssHeight,
val = name === "width" ? elem.offsetWidth : elem.offsetHeight;
if ( extra === "border" ) {
return val;
// Start with offset property
var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
which = name === "width" ? cssWidth : cssHeight;
if ( val > 0 ) {
if ( extra !== "border" ) {
jQuery.each( which, function() {
if ( !extra ) {
val -= parseFloat( jQuery.css( elem, "padding" + this ) ) || 0;
}
if ( extra === "margin" ) {
val += parseFloat( jQuery.css( elem, extra + this ) ) || 0;
} else {
val -= parseFloat( jQuery.css( elem, "border" + this + "Width" ) ) || 0;
}
});
}
return val + "px";
}
jQuery.each( which, function() {
if ( !extra ) {
val -= parseFloat(jQuery.css( elem, "padding" + this )) || 0;
}
// Fall back to computed then uncomputed css if necessary
val = curCSS( elem, name, name );
if ( val < 0 || val == null ) {
val = elem.style[ name ] || 0;
}
// Normalize "", auto, and prepare for extra
val = parseFloat( val ) || 0;
if ( extra === "margin" ) {
val += parseFloat(jQuery.css( elem, "margin" + this )) || 0;
// Add padding, border, margin
if ( extra ) {
jQuery.each( which, function() {
val += parseFloat( jQuery.css( elem, "padding" + this ) ) || 0;
if ( extra !== "padding" ) {
val += parseFloat( jQuery.css( elem, "border" + this + "Width" ) ) || 0;
}
if ( extra === "margin" ) {
val += parseFloat( jQuery.css( elem, extra + this ) ) || 0;
}
});
}
} else {
val -= parseFloat(jQuery.css( elem, "border" + this + "Width" )) || 0;
}
});
return val;
return val + "px";
}
if ( jQuery.expr && jQuery.expr.filters ) {
@ -7957,8 +7997,8 @@ var elemdisplay = {},
],
fxNow,
requestAnimationFrame = window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame;
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame;
jQuery.fn.extend({
show: function( speed, easing, callback ) {
@ -8272,15 +8312,15 @@ jQuery.extend({
// Queueing
opt.old = opt.complete;
opt.complete = function( noUnmark ) {
if ( jQuery.isFunction( opt.old ) ) {
opt.old.call( this );
}
if ( opt.queue !== false ) {
jQuery.dequeue( this );
} else if ( noUnmark !== false ) {
jQuery._unmark( this );
}
if ( jQuery.isFunction( opt.old ) ) {
opt.old.call( this );
}
};
return opt;
@ -8353,7 +8393,7 @@ jQuery.fx.prototype = {
if ( t() && jQuery.timers.push(t) && !timerId ) {
// Use requestAnimationFrame instead of setInterval if available
if ( requestAnimationFrame ) {
timerId = 1;
timerId = true;
raf = function() {
// When timerId gets set to null at any point, this stops
if ( timerId ) {
@ -8516,7 +8556,8 @@ function defaultDisplay( nodeName ) {
if ( !elemdisplay[ nodeName ] ) {
var elem = jQuery( "<" + nodeName + ">" ).appendTo( "body" ),
var body = document.body,
elem = jQuery( "<" + nodeName + ">" ).appendTo( body ),
display = elem.css( "display" );
elem.remove();
@ -8530,14 +8571,15 @@ function defaultDisplay( nodeName ) {
iframe.frameBorder = iframe.width = iframe.height = 0;
}
document.body.appendChild( iframe );
body.appendChild( iframe );
// Create a cacheable copy of the iframe document on first call.
// IE and Opera will allow us to reuse the iframeDoc without re-writing the fake html
// document to it, Webkit & Firefox won't allow reusing the iframe document
// IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML
// document to it; WebKit & Firefox won't allow reusing the iframe document.
if ( !iframeDoc || !iframe.createElement ) {
iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
iframeDoc.write( "<!doctype><html><body></body></html>" );
iframeDoc.write( ( document.compatMode === "CSS1Compat" ? "<!doctype html>" : "" ) + "<html><body>" );
iframeDoc.close();
}
elem = iframeDoc.createElement( nodeName );
@ -8546,7 +8588,7 @@ function defaultDisplay( nodeName ) {
display = jQuery.css( elem, "display" );
document.body.removeChild( iframe );
body.removeChild( iframe );
}
// Store the correct default display
@ -8867,22 +8909,24 @@ function getWindow( elem ) {
// Create innerHeight, innerWidth, outerHeight and outerWidth methods
// Create width, height, innerHeight, innerWidth, outerHeight and outerWidth methods
jQuery.each([ "Height", "Width" ], function( i, name ) {
var type = name.toLowerCase();
// innerHeight and innerWidth
jQuery.fn["inner" + name] = function() {
return this[0] ?
parseFloat( jQuery.css( this[0], type, "padding" ) ) :
jQuery.fn[ "inner" + name ] = function() {
var elem = this[0];
return elem && elem.style ?
parseFloat( jQuery.css( elem, type, "padding" ) ) :
null;
};
// outerHeight and outerWidth
jQuery.fn["outer" + name] = function( margin ) {
return this[0] ?
parseFloat( jQuery.css( this[0], type, margin ? "margin" : "border" ) ) :
jQuery.fn[ "outer" + name ] = function( margin ) {
var elem = this[0];
return elem && elem.style ?
parseFloat( jQuery.css( elem, type, margin ? "margin" : "border" ) ) :
null;
};
@ -8932,5 +8976,6 @@ jQuery.each([ "Height", "Width" ], function( i, name ) {
});
// Expose jQuery to the global object
window.jQuery = window.$ = jQuery;
})(window);

View File

@ -49,7 +49,7 @@ $('table').sortableTable('destroy') - removes all events from the table
},
destroy : function( ) {
$(this).data('sortableTable').destroy();
},
}
};
if ( methods[method] ) {

View File

@ -3,7 +3,8 @@
*
* @param object event data
*/
function onKeyDownArrowsHandler(e) {
function onKeyDownArrowsHandler(e)
{
e = e||window.event;
var o = (e.srcElement||e.target);
if (!o) return;

View File

@ -98,12 +98,28 @@ $js_messages['strMiB'] = __('MiB');
$js_messages['strKiB'] = __('KiB');
$js_messages['strAverageLoad'] = __('Average load');
$js_messages['strTotalMemory'] = __('Total memory');
$js_messages['strCachedMemory'] = __('Cached memory');
$js_messages['strBufferedMemory'] = __('Buffered memory');
$js_messages['strFreeMemory'] = __('Free memory');
$js_messages['strUsedMemory'] = __('Used memory');
$js_messages['strTotalSwap'] = __('Total Swap');
$js_messages['strCachedSwap'] = __('Cached Swap');
$js_messages['strUsedSwap'] = __('Used Swap');
$js_messages['strFreeSwap'] = __('Free Swap');
$js_messages['strBytesSent'] = __('Bytes sent');
$js_messages['strBytesReceived'] = __('Bytes received');
$js_messages['strConnections'] = __('Connections');
$js_messages['strProcesses'] = __('Processes');
/* l10n: Questions is the name of a MySQL Status variable */
$js_messages['strQuestions'] = __('Questions');
$js_messages['strTraffic'] = __('Traffic');
$js_messages['strSettings'] = __('Settings');
$js_messages['strRemoveChart'] = __('Remove chart');
$js_messages['strEditChart'] = __('Edit labels and series');
$js_messages['strEditChart'] = __('Edit title and labels');
$js_messages['strAddChart'] = __('Add chart to grid');
$js_messages['strClose'] = __('Close');
$js_messages['strAddOneSeriesWarning'] = __('Please add at least one variable to the series');
@ -156,6 +172,17 @@ $js_messages['strIgnoreWhereAndGroup'] = __('Group queries, ignoring variable da
$js_messages['strSumRows'] = __('Sum of grouped rows:');
$js_messages['strTotal'] = __('Total:');
$js_messages['strLoadingLogs'] = __('Loading logs');
$js_messages['strRefreshFailed'] = __('Monitor refresh failed');
$js_messages['strInvalidResponseExplanation'] = __('While requesting new chart data the server returned an invalid response. This is most likely because your session expired. Reloading the page and reentering your credentials should help.');
$js_messages['strReloadPage'] = __('Reload page');
$js_messages['strAffectedRows'] = __('Affected rows: ');
$js_messages['strFailedParsingConfig'] = __('Failed parsing config file. It doesn\'t seem to be valid JSON code');
$js_messages['strFailedBuildingGrid'] = __('Failed building chart grid with imported config. Resetting to default config...');
$js_messages['strImport'] = __('Import');
/* For inline query editing */
$js_messages['strGo'] = __('Go');
$js_messages['strCancel'] = __('Cancel');
@ -229,14 +256,14 @@ $js_messages['strAddPolygon'] = __('Add a polygon');
/* For tbl_structure.js */
$js_messages['strAddColumns'] = __('Add columns');
/* Designer (pmd/scripts/move.js) */
/* Designer (js/pmd/move.js) */
$js_messages['strSelectReferencedKey'] = __('Select referenced key');
$js_messages['strSelectForeignKey'] = __('Select Foreign Key');
$js_messages['strPleaseSelectPrimaryOrUniqueKey'] = __('Please select the primary key or a unique key');
$js_messages['strChangeDisplay'] = __('Choose column to display');
$js_messages['strLeavingDesigner'] = __('You haven\'t saved the changes in the layout. They will be lost if you don\'t save them.Do you want to continue?');
/* Visual query builder (pmd/scripts/move.js) */
/* Visual query builder (js/pmd/move.js) */
$js_messages['strAddOption'] = __('Add an option for column ');
/* password generation */

View File

@ -17,7 +17,8 @@ var pma_saveframesize_timeout = null;
* @param string id id of the element in the DOM
* @param boolean only_open do not close/hide element
*/
function toggle(id, only_open) {
function toggle(id, only_open)
{
var el = document.getElementById('subel' + id);
if (! el) {
return false;
@ -104,7 +105,8 @@ function PMA_setFrameSize()
* @param string name name of the value to retrieve
* @return string value value for the given name from cookie
*/
function PMA_getCookie(name) {
function PMA_getCookie(name)
{
var start = document.cookie.indexOf(name + "=");
var len = start + name.length + 1;
if ((!start) && (name != document.cookie.substring(0, name.length))) {
@ -130,7 +132,8 @@ function PMA_getCookie(name) {
* @param string domain
* @param boolean secure
*/
function PMA_setCookie(name, value, expires, path, domain, secure) {
function PMA_setCookie(name, value, expires, path, domain, secure)
{
document.cookie = name + "=" + escape(value) +
( (expires) ? ";expires=" + expires.toGMTString() : "") +
( (path) ? ";path=" + path : "") +
@ -144,7 +147,8 @@ function PMA_setCookie(name, value, expires, path, domain, secure) {
* @param string value requested value
*
*/
function fast_filter(value){
function fast_filter(value)
{
lowercase_value = value.toLowerCase();
$("#subel0 a[class!='tableicon']").each(function(idx,elem){
$elem = $(elem);
@ -160,7 +164,8 @@ function fast_filter(value){
/**
* Clears fast filter.
*/
function clear_fast_filter() {
function clear_fast_filter()
{
var elm = $('#NavFilter input');
elm.val('');
fast_filter('');
@ -170,7 +175,8 @@ function clear_fast_filter() {
/**
* Reloads the recent tables list.
*/
function PMA_reloadRecentTable() {
function PMA_reloadRecentTable()
{
$.get('navigation.php', {
'token': window.parent.token,
'server': window.parent.server,

View File

@ -17,7 +17,8 @@ var g_index;
* @param index has value 1 or 0,decides wheter to hide toggle_container on load.
**/
function panel(index) {
function panel(index)
{
if (!index) {
$(".toggle_container").hide();
}
@ -36,14 +37,15 @@ function panel(index) {
* @uses history_delete()
*
* @param {int} init starting index of unsorted array
* @param {int} final last index of unsorted array
* @param {int} finit last index of unsorted array
*
**/
function display(init,final) {
function display(init,finit)
{
var str,i,j,k,sto;
// this part sorts the history array based on table name,this is needed for clubbing all object of same name together.
for (i = init;i < final;i++) {
for (i = init;i < finit;i++) {
sto = history_array[i];
var temp = history_array[i].get_tab() ;//+ '.' + history_array[i].get_obj_no(); for Self JOINS
for(j = 0;j < i;j++){
@ -99,7 +101,8 @@ function display(init,final) {
*
**/
function and_or(index) {
function and_or(index)
{
if (history_array[index].get_and_or()) {
history_array[index].set_and_or(0);
}
@ -118,7 +121,8 @@ function and_or(index) {
*
**/
function detail (index) {
function detail (index)
{
var type = history_array[index].get_type();
var str;
if (type == "Where") {
@ -158,7 +162,8 @@ function detail (index) {
*
**/
function history_delete(index) {
function history_delete(index)
{
for(var k =0 ;k < from_array.length;k++){
if(from_array[k] == history_array[index].get_tab()){
from_array.splice(k,1);
@ -178,7 +183,8 @@ function history_delete(index) {
*
**/
function history_edit(index) {
function history_edit(index)
{
g_index = index;
var type = history_array[index].get_type();
if (type == "Where") {
@ -225,7 +231,8 @@ function history_edit(index) {
* @param index index of history_array where change is to be made
**/
function edit(type) {
function edit(type)
{
if (type == "Rename") {
if (document.getElementById('e_rename').value != "") {
history_array[g_index].get_obj().setrename_to(document.getElementById('e_rename').value);
@ -271,7 +278,8 @@ function edit(type) {
*
**/
function history(ncolumn_name,nobj,ntab,nobj_no,ntype) {
function history(ncolumn_name,nobj,ntab,nobj_no,ntype)
{
var and_or;
var obj;
var tab;
@ -432,7 +440,8 @@ var aggregate = function(noperator) {
* @return unique array
*/
function unique(arrayName) {
function unique(arrayName)
{
var newArray=new Array();
label:for(var i=0; i<arrayName.length;i++ )
{
@ -454,7 +463,8 @@ function unique(arrayName) {
* @param value value which is to be searched in the array
*/
function found(arrayName,value) {
function found(arrayName,value)
{
for(var i=0; i<arrayName.length; i++) {
if(arrayName[i] == value) { return 1;}
}
@ -474,10 +484,11 @@ function found(arrayName,value) {
* @param fadin
*/
function build_query(formtitle, fadin) {
function build_query(formtitle, fadin)
{
var q_select = "SELECT ";
var temp;
for(i = 0;i < select_field.length; i++) {
for (i = 0;i < select_field.length; i++) {
temp = check_aggregate(select_field[i]);
if (temp != "") {
q_select += temp;
@ -522,8 +533,9 @@ function build_query(formtitle, fadin) {
*/
function query_from() {
var i =0;
function query_from()
{
var i;
var tab_left = [];
var tab_used = [];
var t_tab_used = [];
@ -535,7 +547,7 @@ function query_from() {
var t_array = [];
t_array = from_array;
var K = 0;
for(i; i < history_array.length ; i++) {
for (i = 0; i < history_array.length ; i++) {
from_array.push(history_array[i].get_tab());
}
from_array = unique( from_array );
@ -608,7 +620,8 @@ function query_from() {
* @params add array elements of which are pushed in
* @params arr array in which elemnets are added
*/
function add_array(add,arr){
function add_array(add,arr)
{
for( var i=0; i<add.length; i++){
arr.push(add[i]);
}
@ -621,7 +634,8 @@ function add_array(add,arr){
* @params arr array from which elements are removed.
*
*/
function remove_array(rem,arr){
function remove_array(rem,arr)
{
for(var i=0; i<rem.length; i++){
for(var j=0; j<arr.length; j++)
if(rem[i] == arr[j]) { arr.splice(j,1); }
@ -634,10 +648,11 @@ function remove_array(rem,arr){
*
*/
function query_groupby() {
var i = 0;
function query_groupby()
{
var i;
var str = "";
for(i; i < history_array.length;i++) {
for (i = 0; i < history_array.length;i++) {
if(history_array[i].get_type() == "GroupBy") { str +=history_array[i].get_column_name() + ", ";}
}
str = str.substr(0,str.length -1);
@ -649,10 +664,11 @@ function query_groupby() {
*
*/
function query_having() {
var i = 0;
function query_having()
{
var i;
var and = "(";
for(i; i < history_array.length;i++) {
for (i = 0; i < history_array.length;i++) {
if(history_array[i].get_type() == "Having") {
if (history_array[i].get_obj().get_operator() != 'None') {
and += history_array[i].get_obj().get_operator() + "(" + history_array[i].get_column_name() + " ) " + history_array[i].get_obj().getrelation_operator();
@ -674,10 +690,11 @@ function query_having() {
*
*/
function query_orderby() {
var i = 0;
function query_orderby()
{
var i;
var str = "" ;
for(i; i < history_array.length;i++) {
for (i = 0; i < history_array.length;i++) {
if(history_array[i].get_type() == "OrderBy") { str += history_array[i].get_column_name() + " , "; }
}
str = str.substr(0,str.length -1);
@ -690,11 +707,12 @@ function query_orderby() {
*
*/
function query_where(){
var i = 0;
function query_where()
{
var i;
var and = "(";
var or = "(";
for(i; i < history_array.length;i++) {
for (i = 0; i < history_array.length;i++) {
if(history_array[i].get_type() == "Where") {
if(history_array[i].get_and_or() == 0) {
and += "( " + history_array[i].get_column_name() + " " + history_array[i].get_obj().getrelation_operator() +" " + history_array[i].get_obj().getquery() + ")"; and += " AND ";
@ -721,9 +739,10 @@ function query_where(){
return and;
}
function check_aggregate(id_this) {
var i = 0;
for(i;i < history_array.length;i++) {
function check_aggregate(id_this)
{
var i;
for (i = 0;i < history_array.length;i++) {
var temp = '`' + history_array[i].get_tab() + '`.`' +history_array[i].get_column_name() +'`';
if(temp == id_this && history_array[i].get_type() == "Aggregate") {
return history_array[i].get_obj().get_operator() + '(' + id_this +')';
@ -732,9 +751,10 @@ function check_aggregate(id_this) {
return "";
}
function check_rename(id_this) {
var i = 0;
for (i;i < history_array.length;i++) {
function check_rename(id_this)
{
var i;
for (i = 0;i < history_array.length;i++) {
var temp = '`' + history_array[i].get_tab() + '`.`' +history_array[i].get_column_name() +'`';
if(temp == id_this && history_array[i].get_type() == "Rename") {
return " AS `" + history_array[i].get_obj().getrename_to() +"`";

View File

@ -1038,7 +1038,7 @@ function Select_all(id_this,owner)
downer =owner;
var i;
var tab = [];
for(i = 0; i < parent.elements.length; i++) {
for (i = 0; i < parent.elements.length; i++) {
if (parent.elements[i].type == "checkbox" && parent.elements[i].id.substring(0,(9 + id_this.length)) == 'select_' + id_this + '._') {
if(document.getElementById('select_all_' + id_this).checked == true) {
parent.elements[i].checked = true;
@ -1092,21 +1092,22 @@ function Table_onover(id_this,val,buil)
* In case column is checked it add else it deletes
*
*/
function store_column(id_this,owner,col) {
var i = 0;
var k = 0;
function store_column(id_this,owner,col)
{
var i;
var k;
if (document.getElementById('select_' + owner + '.' + id_this + '._' + col).checked == true) {
select_field.push('`' + id_this + '`.`' + col +'`');
from_array.push(id_this);
}
else {
for(i; i < select_field.length ;i++) {
for (i = 0; i < select_field.length ;i++) {
if (select_field[i] == ('`' + id_this + '`.`' + col +'`')) {
select_field.splice(i,1);
break;
}
}
for(k =0 ;k < from_array.length;k++){
for (k = 0 ;k < from_array.length;k++){
if(from_array[k] == id_this){
from_array.splice(k,1);
break;
@ -1128,7 +1129,8 @@ function store_column(id_this,owner,col) {
* @uses display()
**/
function add_object() {
function add_object()
{
var rel = document.getElementById('rel_opt');
var sum = 0;
var init = history_array.length;

View File

@ -1,13 +1,14 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* for server_replication.php
* for server_replication.php
*
*/
var random_server_id = Math.floor(Math.random() * 10000000);
var conf_prefix = "server-id=" + random_server_id + "<br />log-bin=mysql-bin<br />log-error=mysql-bin.err<br />";
function update_config() {
function update_config()
{
var conf_ignore = "binlog_ignore_db=";
var conf_do = "binlog_do_db=";
var database_list = $('#db_select option:selected:first').val();
@ -30,24 +31,24 @@ $(document).ready(function() {
$('#db_select').change(update_config);
$('#master_status_href').click(function() {
$('#replication_master_section').toggle();
$('#replication_master_section').toggle();
});
$('#master_slaves_href').click(function() {
$('#replication_slaves_section').toggle();
$('#replication_slaves_section').toggle();
});
$('#slave_status_href').click(function() {
$('#replication_slave_section').toggle();
$('#replication_slave_section').toggle();
});
$('#slave_control_href').click(function() {
$('#slave_control_gui').toggle();
$('#slave_control_gui').toggle();
});
$('#slave_errormanagement_href').click(function() {
$('#slave_errormanagement_gui').toggle();
$('#slave_errormanagement_gui').toggle();
});
$('#slave_synchronization_href').click(function() {
$('#slave_synchronization_gui').toggle();
$('#slave_synchronization_gui').toggle();
});
$('#db_reset_href').click(function() {
$('#db_select option:selected').attr('selected', false);
$('#db_select option:selected').attr('selected', false);
});
});

View File

@ -81,7 +81,8 @@ function checkAddUser(the_form)
* @param new_user_initial the first alphabet of the user's name
* @param new_user_initial_string html to replace the initial for pagination
*/
function appendNewUser(new_user_string, new_user_initial, new_user_initial_string) {
function appendNewUser(new_user_string, new_user_initial, new_user_initial_string)
{
//Append the newly retrived user to the table now
//Calculate the index for the new row

View File

@ -218,7 +218,8 @@ $(function() {
true,
numLoadedPoints >= chartObj.options.realtime.numMaxPoints
);
}
},
error: function() { serverResponseError(); }
}
}
@ -260,7 +261,8 @@ $(function() {
true,
numLoadedPoints >= chartObj.options.realtime.numMaxPoints
);
}
},
error: function() { serverResponseError(); }
}
};
@ -295,7 +297,8 @@ $(function() {
true,
numLoadedPoints >= chartObj.options.realtime.numMaxPoints
);
}
},
error: function() { serverResponseError(); }
}
};
} else {
@ -348,7 +351,7 @@ $(function() {
});
$('#filterText').keyup(function(e) {
word = $(this).val().replace('_',' ');
word = $(this).val().replace(/_/g,' ');
if(word.length == 0) textFilter = null;
else textFilter = new RegExp("(^|_)" + word,'i');
@ -363,6 +366,11 @@ $(function() {
filterVariables();
});
$('input#dontFormat').change(function() {
$('#serverstatusvariables td.value span.original').toggle(this.checked);
$('#serverstatusvariables td.value span.formatted').toggle(! this.checked);
});
/* Adjust DOM / Add handlers to the tabs */
function initTab(tab,data) {
switch(tab.attr('id')) {
@ -545,7 +553,55 @@ $(function() {
return pointInfo;
}
/**** Server config advisor ****/
$('a[href="#openAdvisorInstructions"]').click(function() {
$('#advisorInstructionsDialog').dialog();
});
$('a[href="#startAnalyzer"]').click(function() {
var $cnt = $('#statustabs_advisor .tabInnerContent');
$cnt.html('<img class="ajaxIcon" src="' + pmaThemeImage + 'ajax_clock_small.gif" alt="">');
$.get('server_status.php?'+url_query, { ajax_request: true, advisor: true },function(data) {
var $tbody, $tr, str, even = true;
data = $.parseJSON(data);
$cnt.html('<p><b>Possible performance issues</b></p>');
if(data.fired.length > 0) {
$cnt.append('<table class="data" id="rulesFired" border="0"><thead><tr><th>Issue</th><th>Recommendation</th></tr></thead><tbody></tbody></table>');
$tbody = $cnt.find('table#rulesFired');
$.each(data.fired, function(key,value) {
$tbody.append($tr = $('<tr class="linkElem noclick ' + (even ? 'even' : 'odd') + '"><td>' + value.issue + '</td>' +
'<td>' + value.recommendation + ' </td></tr>'));
even = !even;
$tr.data('rule',value);
$tr.click(function() {
var rule = $(this).data('rule');
$('div#emptyDialog').attr('title','Rule details');
$('div#emptyDialog').html(
'<p><b>Issue:</b><br />' + rule.issue + '</p>' +
'<p><b>Recommendation:</b><br />' + rule.recommendation + '</p>' +
'<p><b>Justification:</b><br />' + rule.justification + '</p>' +
'<p><b>Used variable / formula:</b><br />' + rule.formula + '</p>' +
'<p><b>Test:</b><br />' + rule.test + '</p>'
);
$('div#emptyDialog').dialog({
width: 600,
buttons: {
'Close' : function() {
$(this).dialog('close');
}
}
});
});
});
}
});
return false;
});
/**** Monitor charting implementation ****/
@ -555,15 +611,10 @@ $(function() {
var newChart = null;
var chartSpacing;
// Runtime parameter of the monitor
// Runtime parameter of the monitor, is being fully set in initGrid()
var runtime = {
// Holds all visible charts in the grid
charts: null,
// Current max points per chart (needed for auto calculation)
gridMaxPoints: 20,
// displayed time frame
xmin: -1,
xmax: -1,
// Stores the timeout handler so it can be cleared
refreshTimeout: null,
// Stores the GET request to refresh the charts
@ -573,13 +624,18 @@ $(function() {
// To play/pause the monitor
redrawCharts: false,
// Object that contains a list of nodes that need to be retrieved from the server for chart updates
dataList: []
dataList: [],
// Current max points per chart (needed for auto calculation)
gridMaxPoints: 20,
// displayed time frame
xmin: -1,
xmax: -1
};
var monitorSettings = null;
var defaultMonitorSettings = {
columns: 4,
columns: 3,
chartSize: { width: 295, height: 250 },
// Max points in each chart. Settings it to 'auto' sets gridMaxPoints to (chartwidth - 40) / 12
gridMaxPoints: 'auto',
@ -593,20 +649,20 @@ $(function() {
var presetCharts = {
'cpu-WINNT': {
title: PMA_messages['strSystemCPUUsage'],
nodes: [{ dataType: 'cpu', name: 'loadavg', unit: '%'}]
nodes: [{ dataType: 'cpu', name: PMA_messages['strAverageLoad'], dataPoint: 'loadavg', unit: '%'}]
},
'memory-WINNT': {
title: PMA_messages['strSystemMemory'],
nodes: [
{ dataType: 'memory', name: 'MemTotal', valueDivisor: 1024, unit: PMA_messages['strMiB'] },
{ dataType: 'memory', name: 'MemUsed', valueDivisor: 1024, unit: PMA_messages['strMiB'] },
{ dataType: 'memory', name: PMA_messages['strTotalMemory'], dataPoint: 'MemTotal', valueDivisor: 1024, unit: PMA_messages['strMiB'] },
{ dataType: 'memory', name: PMA_messages['strUsedMemory'], dataPoint: 'MemUsed', valueDivisor: 1024, unit: PMA_messages['strMiB'] }
]
},
'swap-WINNT': {
title: PMA_messages['strSystemSwap'],
nodes: [
{ dataType: 'memory', name: 'SwapTotal', valueDivisor: 1024, unit: PMA_messages['strMiB'] },
{ dataType: 'memory', name: 'SwapUsed', valueDivisor: 1024, unit: PMA_messages['strMiB'] },
{ dataType: 'memory', name: PMA_messages['strTotalSwap'], dataPoint: 'SwapTotal', valueDivisor: 1024, unit: PMA_messages['strMiB'] },
{ dataType: 'memory', name: PMA_messages['strUsedSwap'], dataPoint: 'SwapUsed', valueDivisor: 1024, unit: PMA_messages['strMiB'] }
]
},
'cpu-Linux': {
@ -615,25 +671,17 @@ $(function() {
{ dataType: 'cpu',
name: PMA_messages['strAverageLoad'],
unit: '%',
transformFn: function(cur, prev) {
console.log('cpu-linux chart, transformFn()');
console.log(cur);
console.log(prev);
if(prev == null) return undefined;
var diff_total = cur.busy + cur.idle - (prev.busy + prev.idle);
var diff_idle = cur.idle - prev.idle;
return 100*(diff_total - diff_idle) / diff_total;
}
transformFn: 'cpu-linux'
}
]
},
'memory-Linux': {
title: PMA_messages['strSystemMemory'],
nodes: [
{ dataType: 'memory', name: 'MemUsed', valueDivisor: 1024, unit: PMA_messages['strMiB'] },
{ dataType: 'memory', name: 'Cached', valueDivisor: 1024, unit: PMA_messages['strMiB'] },
{ dataType: 'memory', name: 'Buffers', valueDivisor: 1024, unit: PMA_messages['strMiB'] },
{ dataType: 'memory', name: 'MemFree', valueDivisor: 1024, unit: PMA_messages['strMiB'] },
{ dataType: 'memory', name: PMA_messages['strUsedMemory'], dataPoint: 'MemUsed', valueDivisor: 1024, unit: PMA_messages['strMiB'] },
{ dataType: 'memory', name: PMA_messages['strCachedMemory'], dataPoint: 'Cached', valueDivisor: 1024, unit: PMA_messages['strMiB'] },
{ dataType: 'memory', name: PMA_messages['strBufferedMemory'], dataPoint: 'Buffers', valueDivisor: 1024, unit: PMA_messages['strMiB'] },
{ dataType: 'memory', name: PMA_messages['strFreeMemory'], dataPoint:'MemFree', valueDivisor: 1024, unit: PMA_messages['strMiB'] }
],
settings: {
chart: {
@ -650,9 +698,9 @@ $(function() {
'swap-Linux': {
title: PMA_messages['strSystemSwap'],
nodes: [
{ dataType: 'memory', name: 'SwapUsed', valueDivisor: 1024, unit: PMA_messages['strMiB'] },
{ dataType: 'memory', name: 'SwapCached', valueDivisor: 1024, unit: PMA_messages['strMiB'] },
{ dataType: 'memory', name: 'SwapFree', valueDivisor: 1024, unit: PMA_messages['strMiB'] },
{ dataType: 'memory', name: PMA_messages['strTotalSwap'], dataPoint: 'SwapUsed', valueDivisor: 1024, unit: PMA_messages['strMiB'] },
{ dataType: 'memory', name: PMA_messages['strCachedSwap'], dataPoint: 'SwapCached', valueDivisor: 1024, unit: PMA_messages['strMiB'] },
{ dataType: 'memory', name: PMA_messages['strFreeSwap'], dataPoint: 'SwapFree', valueDivisor: 1024, unit: PMA_messages['strMiB'] }
],
settings: {
chart: {
@ -671,18 +719,18 @@ $(function() {
// Default setting
defaultChartGrid = {
'c0': { title: PMA_messages['strQuestions'],
nodes: [{ dataType: 'statusvar', name: 'Questions', display: 'differential' }]
},
'c1': {
nodes: [{ dataType: 'statusvar', name: PMA_messages['strQuestions'], dataPoint: 'Questions', display: 'differential' }]
},
'c1': {
title: PMA_messages['strChartConnectionsTitle'],
nodes: [ { dataType: 'statusvar', name: 'Connections', display: 'differential' },
{ dataType: 'proc', name: 'Processes'} ]
},
'c2': {
nodes: [ { dataType: 'statusvar', name: PMA_messages['strConnections'], dataPoint: 'Connections', display: 'differential' },
{ dataType: 'proc', name: PMA_messages['strProcesses'], dataPoint: 'processes'} ]
},
'c2': {
title: PMA_messages['strTraffic'],
nodes: [
{ dataType: 'statusvar', name: 'Bytes_sent', display: 'differential', valueDivisor: 1024, unit: PMA_messages['strKiB'] },
{ dataType: 'statusvar', name: 'Bytes_received', display: 'differential', valueDivisor: 1024, unit: PMA_messages['strKiB'] }
{ dataType: 'statusvar', name: PMA_messages['strBytesSent'], dataPoint: 'Bytes_sent', display: 'differential', valueDivisor: 1024, unit: PMA_messages['strKiB'] },
{ dataType: 'statusvar', name: PMA_messages['strBytesReceived'], dataPoint: 'Bytes_received', display: 'differential', valueDivisor: 1024, unit: PMA_messages['strKiB'] }
]
}
};
@ -706,7 +754,7 @@ $(function() {
menuItems: [{
textKey: 'editChart',
onclick: function() {
alert('tbi');
editChart(this);
}
}, {
textKey: 'removeChart',
@ -746,9 +794,6 @@ $(function() {
height: 24
},
events: {
start: function() {
// console.log('start.');
},
// Drop event. The drag child element is moved into the drop element
// and vice versa. So the parameters are switched.
drop: function(drag, drop, pos) {
@ -922,14 +967,14 @@ $(function() {
saveMonitor(); // Save settings
$(this).dialog("close");
}
};
dlgButtons[PMA_messages['strClose']] = function() {
newChart = null;
$('span#clearSeriesLink').hide();
$('#seriesPreview').html('');
$(this).dialog("close");
}
};
$('div#addChartDialog').dialog({
width:'auto',
@ -942,13 +987,111 @@ $(function() {
return false;
});
$('a[href="#exportMonitorConfig"]').click(function() {
var gridCopy = {};
$.each(runtime.charts, function(key, elem) {
gridCopy[key] = {};
gridCopy[key].nodes = elem.nodes;
gridCopy[key].settings = elem.settings;
gridCopy[key].title = elem.title;
});
var exportData = {
monitorCharts: gridCopy,
monitorSettings: monitorSettings
};
var $form;
$('body').append($form = $('<form method="post" action="file_echo.php?'+url_query+'&filename=1" style="display:none;"></form>'));
$form.append('<input type="hidden" name="monitorconfig" value="' + encodeURI($.toJSON(exportData)) + '">');
$form.submit();
$form.remove();
});
$('a[href="#importMonitorConfig"]').click(function() {
$('div#emptyDialog').attr('title','Import monitor configuration');
$('div#emptyDialog').html('Please select the file you want to import:<br/><form action="file_echo.php?'+url_query+'&import=1" method="post" enctype="multipart/form-data">'+
'<input type="file" name="file"> <input type="hidden" name="import" value="1"> </form>');
var dlgBtns = {};
dlgBtns[PMA_messages['strImport']] = function() {
var $iframe, $form;
$('body').append($iframe = $('<iframe id="monitorConfigUpload" style="display:none;"></iframe>'));
var d = $iframe[0].contentWindow.document;
d.open(); d.close();
mew = d;
$iframe.load(function() {
var json;
// Try loading config
try {
var data = $('body',$('iframe#monitorConfigUpload')[0].contentWindow.document).html();
// Chrome wraps around '<pre style="word-wrap: break-word; white-space: pre-wrap;">' to any text content -.-
json = $.secureEvalJSON(data.substring(data.indexOf("{"), data.lastIndexOf("}") + 1));
} catch (err) {
alert(PMA_messages['strFailedParsingConfig']);
$('div#emptyDialog').dialog('close');
return;
}
// Basic check, is this a monitor config json?
if(!json || ! json.monitorCharts || ! json.monitorCharts) {
alert(PMA_messages['strFailedParsingConfig']);
$('div#emptyDialog').dialog('close');
return;
}
// If json ok, try applying config
try {
window.localStorage['monitorCharts'] = $.toJSON(json.monitorCharts);
window.localStorage['monitorSettings'] = $.toJSON(json.monitorSettings);
rebuildGrid();
} catch(err) {
alert(PMA_messages['strFailedBuildingGrid']);
// If an exception is thrown, load default again
window.localStorage.removeItem('monitorCharts');
window.localStorage.removeItem('monitorSettings');
rebuildGrid();
}
$('div#emptyDialog').dialog('close');
});
$("body", d).append($form=$('div#emptyDialog').find('form'));
$form.submit();
$('div#emptyDialog').append('<img class="ajaxIcon" src="' + pmaThemeImage + 'ajax_clock_small.gif" alt="">');
};
dlgBtns[PMA_messages['strCancel']] = function() {
$(this).dialog('close');
}
$('div#emptyDialog').dialog({
width: 'auto',
height: 'auto',
buttons: dlgBtns
});
});
$('a[href="#clearMonitorConfig"]').click(function() {
window.localStorage.removeItem('monitorCharts');
window.localStorage.removeItem('monitorSettings');
$(this).hide();
rebuildGrid();
});
$('a[href="#pauseCharts"]').click(function() {
runtime.redrawCharts = ! runtime.redrawCharts;
if(! runtime.redrawCharts)
$(this).html('<img src="themes/dot.gif" class="icon ic_play" alt="" /> ' + PMA_messages['strResumeMonitor']);
else {
$(this).html('<img src="themes/dot.gif" class="icon ic_pause" alt="" /> ' + PMA_messages['strPauseMonitor']);
if(runtime.charts == null) {
if(! runtime.charts) {
initGrid();
$('a[href="#settingsPopup"]').show();
}
@ -1067,7 +1210,7 @@ $(function() {
});
}
);
}
};
loadLogVars();
@ -1133,11 +1276,12 @@ $(function() {
var serie = {
dataType:'statusvar',
dataPoint: $('input#variableInput').attr('value'),
name: $('input#variableInput').attr('value'),
display: $('input[name="differentialValue"]').attr('checked') ? 'differential' : ''
};
if(serie.name == 'Processes') serie.dataType='proc';
if(serie.dataPoint == 'Processes') serie.dataType='proc';
if($('input[name="useDivisor"]').attr('checked'))
serie.valueDivisor = parseInt($('input[name="valueDivisor"]').attr('value'));
@ -1150,7 +1294,7 @@ $(function() {
var str = serie.display == 'differential' ? ', ' + PMA_messages['strDifferential'] : '';
str += serie.valueDivisor ? (', ' + $.sprintf(PMA_messages['strDividedBy'], serie.valueDivisor)) : '';
$('#seriesPreview').append('- ' + serie.name + str + '<br>');
$('#seriesPreview').append('- ' + serie.dataPoint + str + '<br>');
newChart.nodes.push(serie);
@ -1229,11 +1373,57 @@ $(function() {
// Empty cells should keep their size so you can drop onto them
$('table#chartGrid tr td').css('width',chartSize().width + 'px');
buildRequiredDataList();
refreshChartGrid();
}
function destroyGrid() {
if(runtime.charts)
$.each(runtime.charts, function(key, value) {
try {
value.chart.destroy();
} catch(err) {}
});
try {
runtime.refreshRequest.abort();
} catch(err) {}
try {
clearTimeout(runtime.refreshTimeout);
} catch(err) {}
$('table#chartGrid').html('');
runtime.charts = null;
runtime.chartAI = 0;
monitorSettings = null;
}
function rebuildGrid() {
var oldData = null;
if(runtime.charts) {
oldData = {};
$.each(runtime.charts, function(key, chartObj) {
for(var i=0; i < chartObj.nodes.length; i++) {
oldData[chartObj.nodes[i].dataPoint] = [];
for(var j=0; j < chartObj.chart.series[i].data.length; j++)
oldData[chartObj.nodes[i].dataPoint].push([chartObj.chart.series[i].data[j].x, chartObj.chart.series[i].data[j].y]);
}
});
}
destroyGrid();
initGrid();
if(oldData) {
$.each(runtime.charts, function(key, chartObj) {
for(var j=0; j < chartObj.nodes.length; j++) {
if(oldData[chartObj.nodes[j].dataPoint])
chartObj.chart.series[j].setData(oldData[chartObj.nodes[j].dataPoint]);
}
});
}
}
function chartSize() {
var wdt = $('div#logTable').innerWidth() / monitorSettings.columns - (monitorSettings.columns - 1) * chartSpacing.width;
return {
@ -1284,7 +1474,7 @@ $(function() {
$('#logAnalyseDialog').find('dateStart,dateEnd').datepicker('destroy');
$(this).dialog("close");
}
};
dlgBtns[PMA_messages['strFromGeneralLog']] = function() {
var dateStart = Date.parse($('#logAnalyseDialog input[name="dateStart"]').attr('value')) || min;
@ -1301,7 +1491,7 @@ $(function() {
$('#logAnalyseDialog').find('dateStart,dateEnd').datepicker('destroy');
$(this).dialog("close");
}
};
$('#logAnalyseDialog').dialog({
width: 'auto',
@ -1370,10 +1560,58 @@ $(function() {
runtime.chartAI++;
}
function removeChart(chartObj) {
function editChart(chartObj) {
var htmlnode = chartObj.options.chart.renderTo;
if(! htmlnode ) return;
var chart=null;
var chartKey=null;
$.each(runtime.charts, function(key, value) {
if(value.chart.options.chart.renderTo == htmlnode) {
chart = value;
chartKey = key;
return false;
}
});
if(chart == null) return;
var htmlStr = '<p><b>Chart title: </b> <br/> <input type="text" size="35" name="chartTitle" value="' + chart.title + '" />';
htmlStr += '</p><p><b>Series:</b> </p><ol>';
for(var i=0; i<chart.nodes.length; i++) {
htmlStr += '<li><i>' + chart.nodes[i].dataPoint +': </i><br/><input type="text" name="chartSerie-' + i + '" value=" ' + chart.nodes[i].name + '" /></li>';
}
dlgBtns = {};
dlgBtns['Save'] = function() {
runtime.charts[chartKey].title = $('div#emptyDialog input[name="chartTitle"]').attr('value');
runtime.charts[chartKey].chart.setTitle({ text: runtime.charts[chartKey].title });
$('div#emptyDialog input[name*="chartSerie"]').each(function() {
var idx = $(this).attr('name').split('-')[1];
runtime.charts[chartKey].nodes[idx].name = $(this).attr('value');
runtime.charts[chartKey].chart.series[idx].name = $(this).attr('value');
});
$(this).dialog('close');
saveMonitor();
};
dlgBtns['Cancel'] = function() {
$(this).dialog('close');
};
$('div#emptyDialog').attr('title','Edit chart');
$('div#emptyDialog').html(htmlStr+'</ol>');
$('div#emptyDialog').dialog({
width: 'auto',
height: 'auto',
buttons: dlgBtns
});
}
function removeChart(chartObj) {
var htmlnode = chartObj.options.chart.renderTo;
if(! htmlnode ) return;
$.each(runtime.charts, function(key, value) {
if(value.chart.options.chart.renderTo == htmlnode) {
@ -1388,7 +1626,7 @@ $(function() {
// which throws an error when the chart is destroyed
setTimeout(function() {
chartObj.destroy();
$('li#' + htmlnode).remove();
$('div#' + htmlnode).remove();
},10);
saveMonitor(); // Save settings
@ -1397,7 +1635,12 @@ $(function() {
function refreshChartGrid() {
/* Send to server */
runtime.refreshRequest = $.post('server_status.php?'+url_query, { ajax_request: true, chart_data: 1, type: 'chartgrid', requiredData: $.toJSON(runtime.dataList) },function(data) {
var chartData = $.parseJSON(data);
var chartData;
try {
chartData = $.parseJSON(data);
} catch(err) {
return serverResponseError();
}
var value, i=0;
var diff;
@ -1429,9 +1672,10 @@ $(function() {
value = value / elem.nodes[j].valueDivisor;
if(elem.nodes[j].transformFn) {
value = elem.nodes[j].transformFn(
value = chartValueTransform(
elem.nodes[j].transformFn,
chartData[key][j],
(oldChartData == null) ? null : oldChartData[key][j]
(oldChartData == null ? null : oldChartData[key][j])
);
}
@ -1456,6 +1700,17 @@ $(function() {
});
}
function chartValueTransform(name,cur,prev) {
switch(name) {
case 'cpu-linux':
if(prev == null) return undefined;
var diff_total = cur.busy + cur.idle - (prev.busy + prev.idle);
var diff_idle = cur.idle - prev.idle;
return 100*(diff_total - diff_idle) / diff_total;
}
return undefined;
}
/* Build list of nodes that need to be retrieved */
function buildRequiredDataList() {
runtime.dataList = {};
@ -1477,9 +1732,9 @@ $(function() {
if(! opts.limitTypes)
opts.limitTypes = false;
$('#loadingLogsDialog').html(PMA_messages['strAnalysingLogs'] + ' <img class="ajaxIcon" src="' + pmaThemeImage + 'ajax_clock_small.gif" alt="">');
$('#emptyDialog').html(PMA_messages['strAnalysingLogs'] + ' <img class="ajaxIcon" src="' + pmaThemeImage + 'ajax_clock_small.gif" alt="">');
$('#loadingLogsDialog').dialog({
$('#emptyDialog').dialog({
width: 'auto',
height: 'auto',
buttons: {
@ -1503,17 +1758,23 @@ $(function() {
limitTypes: opts.limitTypes
},
function(data) {
var logData = $.parseJSON(data);
var logData;
try {
logData = $.parseJSON(data);
} catch(err) {
return serverResponseError();
}
if(logData.rows.length != 0) {
runtime.logDataCols = buildLogTable(logData);
/* Show some stats in the dialog */
$('#loadingLogsDialog').html('<p>' + PMA_messages['strLogDataLoaded'] + '</p>');
$('#emptyDialog').attr('title', PMA_messages['strLoadingLogs']);
$('#emptyDialog').html('<p>' + PMA_messages['strLogDataLoaded'] + '</p>');
$.each(logData.sum, function(key, value) {
key = key.charAt(0).toUpperCase() + key.slice(1).toLowerCase();
if(key == 'Total') key = '<b>' + key + '</b>';
$('#loadingLogsDialog').append(key + ': ' + value + '<br/>');
$('#emptyDialog').append(key + ': ' + value + '<br/>');
});
/* Add filter options if more than a bunch of rows there to filter */
@ -1551,19 +1812,19 @@ $(function() {
dlgBtns[PMA_messages['strJumpToTable']] = function() {
$(this).dialog("close");
$(document).scrollTop($('div#logTable').offset().top);
}
};
$('#loadingLogsDialog').dialog( "option", "buttons", dlgBtns);
$('#emptyDialog').dialog( "option", "buttons", dlgBtns);
} else {
$('#loadingLogsDialog').html('<p>' + PMA_messages['strNoDataFound'] + '</p>');
$('#emptyDialog').html('<p>' + PMA_messages['strNoDataFound'] + '</p>');
var dlgBtns = {};
dlgBtns[PMA_messages['strClose']] = function() {
$(this).dialog("close");
}
};
$('#loadingLogsDialog').dialog( "option", "buttons", dlgBtns );
$('#emptyDialog').dialog( "option", "buttons", dlgBtns );
}
}
);
@ -1575,18 +1836,29 @@ $(function() {
if(val.length == 0) textFilter = null;
else textFilter = new RegExp(val, 'i');
var rowSum = 0, totalSum = 0;
var i=0, q;
var rowSum = 0, totalSum = 0, i=0, q;
var noVars = $('div#logTable input#noWHEREData').attr('checked');
var equalsFilter = /([^=]+)=(\d+|((\'|"|).*?[^\\])\4((\s+)|$))/gi;
var functionFilter = /([a-z0-9_]+)\(.+?\)/gi;
var filteredQueries = {};
var filteredQueriesLines = {};
var hide = false;
var hide = false, rowData;
var queryColumnName = runtime.logDataCols[runtime.logDataCols.length - 2];
var sumColumnName = runtime.logDataCols[runtime.logDataCols.length - 1];
var isSlowLog = opts.src == 'slow';
var columnSums = {};
var countRow = function(query, row) {
var cells = row.match(/<td>(.*?)<\/td>/gi);
if(!columnSums[query]) columnSums[query] = [0,0,0,0];
columnSums[query][0] += timeToSec(cells[2].replace(/(<td>|<\/td>)/gi,''));
columnSums[query][1] += timeToSec(cells[3].replace(/(<td>|<\/td>)/gi,''));
columnSums[query][2] += parseInt(cells[4].replace(/(<td>|<\/td>)/gi,''));
columnSums[query][3] += parseInt(cells[5].replace(/(<td>|<\/td>)/gi,''));
};
// We just assume the sql text is always in the second last column, and that the total count is right of it
$('div#logTable table tbody tr td:nth-child(' + (runtime.logDataCols.length - 1) + ')').each(function() {
if(varFilterChange && $(this).html().match(/^SELECT/i)) {
@ -1604,10 +1876,23 @@ $(function() {
filteredQueriesLines[q] = i;
$(this).text(q);
}
if(isSlowLog) countRow(q, $(this).parent().html());
// Restore original columns
} else {
$(this).text($(this).parent().data('query')[queryColumnName]);
$(this).next().text($(this).parent().data('query')[sumColumnName]);
rowData = $(this).parent().data('query');
// SQL Text
$(this).text(rowData[queryColumnName]);
// #
$(this).next().text(rowData[sumColumnName]);
// Slow log columns
if(isSlowLog) {
$(this).parent().children('td:nth-child(3)').text(rowData['query_time']);
$(this).parent().children('td:nth-child(4)').text(rowData['lock_time']);
$(this).parent().children('td:nth-child(5)').text(rowData['rows_sent']);
$(this).parent().children('td:nth-child(6)').text(rowData['rows_examined']);
}
}
}
@ -1634,21 +1919,28 @@ $(function() {
i++;
});
// Update count values of grouped entries
if(varFilterChange) {
if(noVars) {
var numCol, row, $table = $('div#logTable table tbody');
$.each(filteredQueriesLines, function(key,value) {
if(filteredQueries[value] <= 1) return;
var numCol = $('div#logTable table tbody tr:nth-child(' + (value+1) + ')')
.children(':nth-child(' + (runtime.logDataCols.length) + ')');
if(filteredQueries[key] <= 1) return;
row = $table.children('tr:nth-child(' + (value+1) + ')');
numCol = row.children(':nth-child(' + (runtime.logDataCols.length) + ')');
numCol.text(filteredQueries[key]);
if(isSlowLog) {
row.children('td:nth-child(3)').text(secToTime(columnSums[key][0]));
row.children('td:nth-child(4)').text(secToTime(columnSums[key][1]));
row.children('td:nth-child(5)').text(columnSums[key][2]);
row.children('td:nth-child(6)').text(columnSums[key][3]);
}
});
}
$('div#logTable table').trigger("update");
setTimeout(function() {
$('div#logTable table').trigger('sorton',[[[runtime.logDataCols.length - 1,1]]]);
}, 0);
}
@ -1668,6 +1960,24 @@ $(function() {
limitTypes: true
});*/
function timeToSec(timeStr) {
var time = timeStr.split(':');
return parseInt(time[0]*3600) + parseInt(time[1]*60) + parseInt(time[2]);
}
function secToTime(timeInt) {
hours = Math.floor(timeInt / 3600);
timeInt -= hours*3600;
minutes = Math.floor(timeInt / 60);
timeInt -= minutes*60;
if(hours < 10) hours = '0' + hours;
if(minutes < 10) minutes = '0' + minutes;
if(timeInt < 10) timeInt = '0' + timeInt;
return hours + ':' + minutes + ':' + timeInt;
}
function buildLogTable(data) {
var rows = data.rows;
var cols = new Array();
@ -1682,7 +1992,7 @@ $(function() {
return value.replace(/(\[.*?\])+/g,'');
}
return value;
}
};
for(var i=0; i < rows.length; i++) {
if(i == 0) {
@ -1701,7 +2011,7 @@ $(function() {
for(var j=0; j < cols.length; j++) {
// Assuming the query column is the second last
if(j == cols.length - 2 && rows[i][cols[j]].match(/^SELECT/i)) {
$tRow.append($tCell=$('<td class="analyzableQuery">' + formatValue(cols[j], rows[i][cols[j]]) + '</td>'));
$tRow.append($tCell=$('<td class="linkElem">' + formatValue(cols[j], rows[i][cols[j]]) + '</td>'));
$tCell.click(queryAnalyzer);
} else
$tRow.append('<td>' + formatValue(cols[j], rows[i][cols[j]]) + '</td>');
@ -1718,13 +2028,17 @@ $(function() {
function queryAnalyzer() {
var query = $(this).parent().data('query')[cols[cols.length-2]];
var query = $(this).parent().data('query').argument || $(this).parent().data('query').sql_text;
var db = $(this).parent().data('query').db || '';
/* A very basic SQL Formatter. Totally fails in the cases of
- Any string appearance containing a MySQL Keyword, surrounded by whitespaces
- Any string appearance containing a MySQL Keyword, surrounded by whitespaces, e.g. WHERE bar = "This where the formatter fails"
- Subqueries too probably
*/
// .* selector doesn't includde whitespace, [^] doesn't work in IE8, thus we use [^\0] since the zero-byte char (hopefully) doesn't appear in table names ;)
// Matches the columns to be selected
// .* selector doesn't include whitespace and we have no PCRE_DOTALL modifier, (.|\s)+ crashes Chrome (reported and confirmed),
// [^]+ results in JS error in IE8, thus we use [^\0]+ for matching each column since the zero-byte char (hopefully) doesn't appear in column names ;)
var sLists = query.match(/SELECT\s+[^\0]+\s+FROM\s+/gi);
if(sLists) {
for(var i=0; i < sLists.length; i++) {
@ -1752,7 +2066,8 @@ $(function() {
$.post('server_status.php?'+url_query, {
ajax_request: true,
query_analyzer: true,
query: codemirror_editor.getValue()
query: codemirror_editor.getValue(),
database: db
}, function(data) {
data = $.parseJSON(data);
var totalTime = 0;
@ -1766,14 +2081,39 @@ $(function() {
$('div#queryAnalyzerDialog div.placeHolder')
.html('<table width="100%" border="0"><tr><td class="explain"></td><td class="chart"></td></tr></table>');
var explain = '<b>Explain output</b><p></p>';
$.each(data.explain, function(key,value) {
value = (value==null)?'null':value;
var explain = '<b>Explain output</b> '+explain_docu;
if(data.explain.length > 1) {
explain += ' (';
for(var i=0; i < data.explain.length; i++) {
if(i > 0) explain += ', ';
explain += '<a href="#showExplain-' + i + '">' + i + '</a>';
}
explain += ')';
}
explain +='<p></p>';
for(var i=0; i < data.explain.length; i++) {
explain += '<div class="explain-' + i + '"' + (i>0? 'style="display:none;"' : '' ) + '>';
$.each(data.explain[i], function(key,value) {
value = (value==null)?'null':value;
if(key == 'type' && value.toLowerCase() == 'all') value = '<span class="attention">' + value +'</span>';
if(key == 'Extra') value = value.replace(/(using (temporary|filesort))/gi,'<span class="attention">$1</span>');
explain += key+': ' + value + '<br />';
});
explain += '</div>';
}
// Since there is such a nice free space below the explain, lets put it here for now
explain += '<p><b>' + PMA_messages['strAffectedRows'] + '</b> ' + data.affectedRows;
explain += key+': ' + value + '<br />';
});
$('div#queryAnalyzerDialog div.placeHolder td.explain').append(explain);
$('div#queryAnalyzerDialog div.placeHolder a[href*="#showExplain"]').click(function() {
var id = $(this).attr('href').split('-')[1];
$(this).parent().find('div[class*="explain"]').hide();
$(this).parent().find('div[class*="explain-' + id + '"]').show();
});
if(data.profiling) {
var chartData = [];
var numberTable = '<table class="queryNums"><thead><tr><th>Status</th><th>Time</th></tr></thead><tbody>';
@ -1790,7 +2130,7 @@ $(function() {
numberTable += '<tr><td><b>Total time:</b></td><td>' + PMA_prettyProfilingNum(totalTime,2) + '</td></tr>';
numberTable += '</tbody></table>';
$('div#queryAnalyzerDialog div.placeHolder td.chart').append('<b>Profiling results</b> (<a href="#showNums">Table</a> | <a href="#showChart">Chart</a>)<br/>' + numberTable + ' <div id="queryProfiling"></div>');
$('div#queryAnalyzerDialog div.placeHolder td.chart').append('<b>Profiling results ' + profiling_docu + '</b> (<a href="#showNums">Table</a>, <a href="#showChart">Chart</a>)<br/>' + numberTable + ' <div id="queryProfiling"></div>');
$('div#queryAnalyzerDialog div.placeHolder a[href="#showNums"]').click(function() {
$('div#queryAnalyzerDialog div#queryProfiling').hide();
@ -1883,10 +2223,14 @@ $(function() {
$('a[href="#clearMonitorConfig"]').show();
}
$('a[href="#clearMonitorConfig"]').click(function() {
window.localStorage.removeItem('monitorCharts');
window.localStorage.removeItem('monitorSettings');
$(this).hide();
});
function serverResponseError() {
var btns = {};
btns[PMA_messages['strReloadPage']] = function() {
window.location.reload();
};
$('#emptyDialog').attr('title',PMA_messages['strRefreshFailed']);
$('#emptyDialog').html('<img class="icon ic_s_attention" src="themes/dot.gif" alt=""> ' + PMA_messages['strInvalidResponseExplanation'])
$('#emptyDialog').dialog({ buttons: btns });
}
});

View File

@ -226,33 +226,23 @@ function showDetails(i, update_size, insert_size, remove_size, insert_index, rem
*/
function ApplySelectedChanges(token)
{
var div = document.getElementById("list");
var table = div.getElementsByTagName('table')[0];
var table_body = table.getElementsByTagName('tbody')[0];
// Get all the rows from the details table
var table_rows = table_body.getElementsByTagName('tr');
var x = table_rows.length;
var i;
/**
Append the token at the beginning of the query string followed by
Table_ids that shows that "Apply Selected Changes" button is pressed
*/
var append_string = "?token="+token+"&Table_ids="+1;
for(i=0; i<x; i++){
append_string += "&";
append_string += i+"="+table_rows[i].id;
var params = {
token: $('#synchronize_form input[name=token]').val(),
server: $('#synchronize_form input[name=server]').val(),
checked: $('#delete_rows').prop('checked') ? 'true' : 'false',
Table_ids: 1
};
var $rows = $('#list tbody tr');
for(var i = 0; i < $rows.length; i++) {
params[i] = $($rows[i]).attr('id');
}
// Getting the value of checkbox delete_rows
var checkbox = document.getElementById("delete_rows");
if (checkbox.checked){
append_string += "&checked=true";
} else {
append_string += "&checked=false";
}
//Appending the token and list of table ids in the URL
location.href += token;
location.href += append_string;
location.href += '?' + $.param(params);
}

View File

@ -1,13 +1,14 @@
function editVariable(link) {
function editVariable(link)
{
var varName = $(link).parent().parent().find('th:first').first().text().replace(/ /g,'_');
var mySaveLink = $(saveLink);
var myCancelLink = $(cancelLink);
var $cell = $(link).parent();
$cell.addClass('edit');
// remove edit link
$cell.find('a.editLink').remove();
mySaveLink.click(function() {
$.get('server_variables.php?' + url_query,
{ ajax_request: true, type: 'setval', varName: varName, varValue: $cell.find('input').attr('value') },
@ -23,14 +24,14 @@ function editVariable(link) {
);
return false;
});
myCancelLink.click(function() {
$cell.html($cell.find('span.oldContent').html());
$cell.removeClass('edit');
return false;
});
$.get('server_variables.php?' + url_query,
{ ajax_request: true, type: 'getval', varName: varName },
function(data) {
@ -42,17 +43,17 @@ function editVariable(link) {
$cell.find('table td:first').append(myCancelLink);
}
);
return false;
}
$(function() {
$(function() {
var textFilter=null;
var odd_row=false;
var testString = 'abcdefghijklmnopqrstuvwxyz0123456789,ABCEFGHIJKLMOPQRSTUVWXYZ';
var $tmpDiv;
var charWidth;
// Global vars
editLink = '<a href="#" class="editLink" onclick="return editVariable(this);"><img class="icon ic_b_edit" src="themes/dot.gif" alt=""> '+PMA_messages['strEdit']+'</a>';
saveLink = '<a href="#" class="saveLink"><img class="icon ic_b_save" src="themes/dot.gif" alt=""> '+PMA_messages['strSave']+'</a> ';
@ -62,7 +63,7 @@ $(function() {
$.ajaxSetup({
cache:false
});
/* Variable editing */
if(isSuperuser) {
$('table.data tbody tr td:nth-child(2)').hover(
@ -76,36 +77,36 @@ $(function() {
}
);
}
/*** This code snippet takes care that the table stays readable. It cuts off long strings the table overlaps the window size ***/
$('table.data').after($tmpDiv=$('<span>'+testString+'</span>'));
charWidth = $tmpDiv.width() / testString.length;
$tmpDiv.remove();
$(window).resize(limitTableWidth);
limitTableWidth();
function limitTableWidth() {
var fulltext;
var charDiff;
var maxTableWidth;
var $tmpTable;
$('table.data').after($tmpTable=$('<table id="testTable" style="width:100%;"><tr><td>'+testString+'</td></tr></table>'));
maxTableWidth = $('#testTable').width();
maxTableWidth = $('#testTable').width();
$tmpTable.remove();
charDiff = ($('table.data').width()-maxTableWidth) / charWidth;
if($('body').innerWidth() < $('table.data').width()+10 || $('body').innerWidth() > $('table.data').width()+20) {
var maxChars=0;
$('table.data tbody tr td:nth-child(2)').each(function() {
maxChars=Math.max($(this).text().length,maxChars);
});
// Do not resize smaller if there's only 50 chars displayed already
if(charDiff > 0 && maxChars < 50) return;
$('table.data tbody tr td:nth-child(2)').each(function() {
if((charDiff>0 && $(this).text().length > maxChars-charDiff) || (charDiff<0 && $(this).find('abbr.cutoff').length>0)) {
if($(this).find('abbr.cutoff').length > 0)
@ -115,7 +116,7 @@ $(function() {
// Do not cut off elements with html in it and hope they are not too long
if(fulltext.length != $(this).html().length) return 0;
}
if(fulltext.length < maxChars-charDiff)
$(this).html(fulltext);
else $(this).html('<abbr class="cutoff" title="'+fulltext+'">'+fulltext.substr(0,maxChars-charDiff-3)+'...</abbr>');
@ -123,31 +124,31 @@ $(function() {
});
}
}
// Filter options are invisible for disabled js users
$('fieldset#tableFilter').css('display','');
$('#filterText').keyup(function(e) {
if($(this).val().length==0) textFilter=null;
else textFilter = new RegExp("(^| )"+$(this).val().replace('_',' '),'i');
else textFilter = new RegExp("(^| )"+$(this).val().replace(/_/g,' '),'i');
filterVariables();
});
function filterVariables() {
odd_row=false;
var mark_next=false;
var firstCell;
$('table.filteredData tbody tr').each(function() {
firstCell = $(this).children(':first');
if(mark_next || textFilter==null || textFilter.exec(firstCell.text())) {
// If current row is 'marked', also display next row
if($(this).hasClass('marked') && !mark_next)
mark_next=true;
else mark_next=false;
odd_row = !odd_row;
odd_row = !odd_row;
$(this).css('display','');
if(odd_row) {
$(this).addClass('odd');
@ -161,4 +162,4 @@ $(function() {
}
});
}
});
});

View File

@ -15,11 +15,13 @@ var $data_a;
* @param string str
* @return string the URL-decoded string
*/
function PMA_urldecode(str) {
function PMA_urldecode(str)
{
return decodeURIComponent(str.replace(/\+/g, '%20'));
}
function PMA_urlencode(str) {
function PMA_urlencode(str)
{
return encodeURIComponent(str.replace(/\%20/g, '+'));
}
@ -29,7 +31,8 @@ function PMA_urlencode(str) {
*
* @param $this_field jQuery object that points to the current field's tr
*/
function getFieldName($this_field) {
function getFieldName($this_field)
{
var this_field_index = $this_field.index();
// ltr or rtl direction does not impact how the DOM was generated
@ -52,7 +55,8 @@ function getFieldName($this_field) {
* new inline edit anchor to each table row.
*
*/
function appendInlineAnchor() {
function appendInlineAnchor()
{
// TODO: remove two lines below if vertical display mode has been completely removed
var disp_mode = $("#top_direction_dropdown").val();
@ -1096,7 +1100,8 @@ $(document).ready(function() {
* (when called in the situation where no posting was done, the data
* parameter is empty)
*/
function PMA_unInlineEditRow($del_hide, $chg_submit, $this_td, $input_siblings, data) {
function PMA_unInlineEditRow($del_hide, $chg_submit, $this_td, $input_siblings, data)
{
// deleting the hide button. remove <br><br><a> tags
$del_hide.find('a, br').remove();
@ -1189,7 +1194,8 @@ function PMA_unInlineEditRow($del_hide, $chg_submit, $this_td, $input_siblings,
* Starting from some th, change the class of all td under it.
* If isAddClass is specified, it will be used to determine whether to add or remove the class.
*/
function PMA_changeClassForColumn($this_th, newclass, isAddClass) {
function PMA_changeClassForColumn($this_th, newclass, isAddClass)
{
// index 0 is the th containing the big T
var th_index = $this_th.index();
var has_big_t = !$this_th.closest('tr').children(':first').hasClass('column_heading');
@ -1238,7 +1244,8 @@ $(document).ready(function() {
/*
* Profiling Chart
*/
function makeProfilingChart() {
function makeProfilingChart()
{
if ($('#profilingchart').length == 0) {
return;
}

View File

@ -64,7 +64,8 @@ function nullify(theType, urlField, md5Field, multi_edit)
* Start of validation part
*/
//function checks the number of days in febuary
function daysInFebruary (year){
function daysInFebruary (year)
{
return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
//function to convert single digit to double digit
@ -143,7 +144,8 @@ function isTime(val)
return true;
}
function verificationsAfterFieldChange(urlField, multi_edit, theType){
function verificationsAfterFieldChange(urlField, multi_edit, theType)
{
var evt = window.event || arguments.callee.caller.arguments[0];
var target = evt.target || evt.srcElement;

View File

@ -7,25 +7,25 @@ $(document).ready(function() {
var chart_data = jQuery.parseJSON($('#querychart').html());
chart_series = 'columns';
chart_xaxis_idx = $('select[name="chartXAxis"]').attr('value');
$('#resizer').resizable({
minHeight:240,
minWidth:300,
// On resize, set the chart size to that of the
// On resize, set the chart size to that of the
// resizer minus padding. If your chart has a lot of data or other
// content, the redrawing might be slow. In that case, we recommend
// content, the redrawing might be slow. In that case, we recommend
// that you use the 'stop' event instead of 'resize'.
resize: function() {
currentChart.setSize(
this.offsetWidth - 20,
this.offsetWidth - 20,
this.offsetHeight - 20,
false
);
}
});
});
var currentSettings = {
chart: {
chart: {
type: 'line',
width: $('#resizer').width() - 20,
height: $('#resizer').height() - 20
@ -36,28 +36,28 @@ $(document).ready(function() {
yAxis: {
title: { text: $('input[name="yaxis_label"]').attr('value') }
},
title: {
text: $('input[name="chartTitle"]').attr('value'),
margin:20
title: {
text: $('input[name="chartTitle"]').attr('value'),
margin:20
},
plotOptions: {
series: {}
}
}
$('#querychart').html('');
$('input[name="chartType"]').click(function() {
currentSettings.chart.type = $(this).attr('value');
drawChart();
if($(this).attr('value') == 'bar' || $(this).attr('value') == 'column')
$('span.barStacked').show();
else
$('span.barStacked').hide();
});
$('input[name="barStacked"]').click(function() {
if(this.checked)
$.extend(true,currentSettings,{ plotOptions: { series: { stacking:'normal' } } });
@ -65,13 +65,13 @@ $(document).ready(function() {
$.extend(true,currentSettings,{ plotOptions: { series: { stacking:null } } });
drawChart();
});
$('input[name="chartTitle"]').keyup(function() {
var title = $(this).attr('value');
if(title.length == 0) title = ' ';
currentChart.setTitle({ text: title });
});
$('select[name="chartXAxis"]').change(function() {
chart_xaxis_idx = this.value;
drawChart();
@ -81,7 +81,7 @@ $(document).ready(function() {
chart_series_index = this.selectedIndex;
drawChart();
});
/* Sucks, we cannot just set axis labels, we have to redraw the chart completely */
$('input[name="xaxis_label"]').keyup(function() {
currentSettings.xAxis.title.text = $(this).attr('value');
@ -91,56 +91,58 @@ $(document).ready(function() {
currentSettings.yAxis.title.text = $(this).attr('value');
drawChart(true);
});
function drawChart(noAnimation) {
currentSettings.chart.width = $('#resizer').width() - 20;
currentSettings.chart.height = $('#resizer').height() - 20;
if(currentChart != null) currentChart.destroy();
if(noAnimation) currentSettings.plotOptions.series.animation = false;
currentChart = PMA_queryChart(chart_data,currentSettings);
if(noAnimation) currentSettings.plotOptions.series.animation = true;
}
drawChart();
$('#querychart').show();
});
function in_array(element,array) {
function in_array(element,array)
{
for(var i=0; i < array.length; i++)
if(array[i] == element) return true;
return false;
}
function PMA_queryChart(data,passedSettings) {
function PMA_queryChart(data,passedSettings)
{
if($('#querychart').length == 0) return;
var columnNames = Array();
var series = new Array();
var xaxis = { type: 'linear' };
var yaxis = new Object();
$.each(data[0],function(index,element) {
columnNames.push(index);
});
});
switch(passedSettings.chart.type) {
case 'column':
case 'spline':
case 'line':
case 'bar':
xaxis.categories = new Array();
if(chart_series == 'columns') {
var j = 0;
for(var i=0; i<columnNames.length; i++)
for(var i=0; i<columnNames.length; i++)
if(i != chart_xaxis_idx) {
series[j] = new Object();
series[j].data = new Array();
series[j].name = columnNames[i];
$.each(data,function(key,value) {
series[j].data.push(parseFloat(value[columnNames[i]]));
if( j== 0 && chart_xaxis_idx != -1 && ! xaxis.categories[value[columnNames[chart_xaxis_idx]]])
@ -156,7 +158,7 @@ function PMA_queryChart(data,passedSettings) {
var contains = false;
for(var i=0; i < series.length; i++)
if(series[i].name == element[chart_series]) contains = true;
if(!contains) {
seriesIndex[element[chart_series]] = j;
series[j] = new Object();
@ -165,24 +167,24 @@ function PMA_queryChart(data,passedSettings) {
j++;
}
});
var type;
// Get series points from query data
$.each(data,function(key,value) {
type = value[chart_series];
series[seriesIndex[type]].data.push(parseFloat(value[columnNames[0]]));
if( !in_array(value[columnNames[chart_xaxis_idx]],xaxis.categories))
xaxis.categories.push(value[columnNames[chart_xaxis_idx]]);
});
}
if(columnNames.length == 2)
yaxis.title = { text: columnNames[0] };
break;
case 'pie':
series[0] = new Object();
series[0].data = new Array();
@ -194,17 +196,17 @@ function PMA_queryChart(data,passedSettings) {
});
break;
}
// Prevent the user from seeing the JSON code
$('div#profilingchart').html('').show();
var settings = {
chart: {
chart: {
renderTo: 'querychart'
},
title: {
text: '',
margin: 0
title: {
text: '',
margin: 0
},
series: series,
xAxis: xaxis,
@ -224,17 +226,17 @@ function PMA_queryChart(data,passedSettings) {
},
tooltip: {
formatter: function() {
if(this.point.name) return '<b>'+this.series.name+'</b><br/>'+this.point.name+'<br/>'+this.y;
return '<b>'+this.series.name+'</b><br/>'+this.y;
if(this.point.name) return '<b>'+this.series.name+'</b><br/>'+this.point.name+'<br/>'+this.y;
return '<b>'+this.series.name+'</b><br/>'+this.y;
}
}
};
if(passedSettings.chart.type == 'pie')
settings.tooltip.formatter = function() { return '<b>'+columnNames[0]+'</b><br/>'+this.y; }
// Overwrite/Merge default settings with passedsettings
$.extend(true,settings,passedSettings);
return PMA_createChart(settings);
}

View File

@ -17,7 +17,8 @@ var svg;
/**
* Zooms and pans the visualization.
*/
function zoomAndPan() {
function zoomAndPan()
{
var g = svg.getElementById('groupPanel');
g.setAttribute('transform', 'translate(' + x + ', ' + y + ') scale(' + scale + ')');
@ -245,7 +246,7 @@ $(document).ready(function() {
y = height / 2 - (height / 2 - y) * 1.5;
zoomAndPan();
});
$('#zoom_world').live('click', function(e) {
e.preventDefault();
scale = 1;
@ -253,7 +254,7 @@ $(document).ready(function() {
y = default_y;
zoomAndPan();
});
$('#zoom_out').live('click', function(e) {
e.preventDefault();
//zoom out
@ -311,7 +312,7 @@ $(document).ready(function() {
}).appendTo("body").fadeIn(200);
}
});
/**
* Detect the mouseout event and hide tooltips.
*/

View File

@ -1,9 +1,10 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* for tbl_relation.php
* for tbl_relation.php
*
*/
function show_hide_clauses(thisDropdown) {
function show_hide_clauses(thisDropdown)
{
// here, one span contains the label and the clause dropdown
// and we have one span for ON DELETE and one for ON UPDATE
//

View File

@ -341,7 +341,7 @@ $(document).ready(function() {
**/
$("#addColumns.ajax input[value=Go]").live('click', function(event){
event.preventDefault();
/*Remove the hidden dialogs if there are*/
if ($('#add_columns').length != 0) {
$('#add_columns').remove();
@ -349,7 +349,7 @@ $(document).ready(function() {
var $div = $('<div id="add_columns"></div>');
var $form = $("#addColumns");
/**
* @var button_options Object that stores the options passed to jQueryUI
* dialog
@ -389,7 +389,7 @@ $(document).ready(function() {
//Remove the top menu container from the dialog
.find("#topmenucontainer").hide()
; // end dialog options
$div = $("#add_columns");
/*changed the z-index of the enum editor to allow the edit*/
$("#enum_editor").css("z-index", "1100");
@ -399,7 +399,7 @@ $(document).ready(function() {
}) // end $.get()
});
}) // end $(document).ready()
@ -411,7 +411,8 @@ $(document).ready(function() {
* @param string $url Variable which parses the data for the
* post action
*/
function changeColumns(action,url) {
function changeColumns(action,url)
{
/*Remove the hidden dialogs if there are*/
if ($('#change_column_dialog').length != 0) {
$('#change_column_dialog').remove();

View File

@ -10,13 +10,14 @@ var hash_init_done = 0;
/**
* Sets hash part in URL, either calls itself in parent frame or does the
* work itself. The hash is not set directly if we did not yet process old
* work itself. The hash is not set directly if we did not yet process old
* one.
*/
function setURLHash(hash) {
function setURLHash(hash)
{
if (jQuery.browser.webkit) {
/*
* Setting hash leads to reload in webkit:
/*
* Setting hash leads to reload in webkit:
* http://www.quirksmode.org/bugreports/archives/2005/05/Safari_13_visual_anomaly_with_windowlocationhref.html
*/
return;

View File

@ -300,7 +300,7 @@ class PMA_Table
if (! isset(PMA_Table::$cache[$db][$table][$info])) {
if (! $disable_error) {
trigger_error('unknown table status: ' . $info, E_USER_WARNING);
trigger_error(__('unknown table status: ') . $info, E_USER_WARNING);
}
return false;
}
@ -1338,7 +1338,7 @@ class PMA_Table
}
} else if ($property == self::PROP_COLUMN_ORDER ||
$property == self::PROP_COLUMN_VISIB) {
if (isset($this->uiprefs[$property])) {
if (! PMA_Table::isView($this->db_name, $this->name) && isset($this->uiprefs[$property])) {
// check if the table has not been modified
if (self::sGetStatusInfo($this->db_name, $this->name, 'Create_time') ==
$this->uiprefs['CREATE_TIME']) {
@ -1376,8 +1376,8 @@ class PMA_Table
$this->loadUiPrefs();
}
// we want to save the create time if the property is PROP_COLUMN_ORDER
if ($property == self::PROP_COLUMN_ORDER ||
$property == self::PROP_COLUMN_VISIB) {
if (! PMA_Table::isView($this->db_name, $this->name) && ($property == self::PROP_COLUMN_ORDER ||
$property == self::PROP_COLUMN_VISIB)) {
$curr_create_time = self::sGetStatusInfo($this->db_name, $this->name, 'CREATE_TIME');
if (isset($table_create_time) &&

View File

@ -16,7 +16,8 @@
*
* @package phpMyAdmin
*/
class PMA_Theme {
class PMA_Theme
{
/**
* @var string theme version
* @access protected

199
libraries/advisor.lib.php Normal file
View File

@ -0,0 +1,199 @@
<?php
class Advisor
{
var $variables;
var $parseResult;
var $runResult;
function run() {
// HowTo: A simple Advisory system in 3 easy steps.
// Step 1: Get some variables to evaluate on
$this->variables = array_merge(PMA_DBI_fetch_result('SHOW GLOBAL STATUS', 0, 1), PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES', 0, 1));
// Step 2: Read and parse the list of rules
$this->parseResult = $this->parseRulesFile();
// Step 3: Feed the variables to the rules and let them fire. Sets $runResult
$this->runRules();
/* echo '<br/><hr>';
echo 'Total rules: '.count($this->parseResult['rules']).' <br><br>';
echo '<b>Possible performance issues</b><br/>';
foreach($this->runResult['fired'] as $rule) {
echo $rule['issue'].'<br />';
}
echo '<br/><b>Rules not checked due to unmet preconditions</b><br/>';
foreach($this->runResult['unchecked'] as $rule) {
echo $rule['name'].'<br />';
}
echo '<br/><b>Rules that didn\'t fire</b><br/>';
foreach($this->runResult['notfired'] as $rule) {
echo $rule['name'].'<br />';
}
if($this->runResult['errors'])
echo 'There were errors while testing the rules.';
*/
return $this->runResult;
}
function runRules() {
$this->runResult = array( 'fired' => array(), 'notfired' => array(), 'unchecked'=> array(), 'errors' => array() );
foreach($this->parseResult['rules'] as $rule) {
$this->variables['value'] = 0;
$precond = true;
if(isset($rule['precondition'])) {
try {
$precond = $this->ruleExprEvaluate($rule['precondition']);
} catch (Exception $e) {
$this->runResult['errors'][] = 'Failed evaluating precondition for rule \''.$rule['name'].'\'. PHP threw following error: '.$e->getMessage();
continue;
}
}
if(! $precond)
$this->addRule('unchecked', $rule);
else {
try {
$value = $this->ruleExprEvaluate($rule['formula']);
} catch(Exception $e) {
$this->runResult['errors'][] = 'Failed calculating value for rule \''.$rule['name'].'\'. PHP threw following error: '.$e->getMessage();
continue;
}
$this->variables['value'] = $value;
try {
if($this->ruleExprEvaluate($rule['test']))
$this->addRule('fired', $rule);
else $this->addRule('notfired', $rule);
} catch(Exception $e) {
$this->runResult['errors'][] = 'Failed running test for rule \''.$rule['name'].'\'. PHP threw following error: '.$e->getMessage();
}
}
}
return true;
}
function addRule($type, $rule) {
switch($type) {
case 'notfired':
case 'fired':
$jst = preg_split('/\s*\|\s*/',$rule['justification'],2);
if(count($jst) > 1) {
$jst[0] = preg_replace('/%( |,|\.|$)/','%%\1',$jst[0]);
try {
$str = $this->ruleExprEvaluate('sprintf("'.$jst[0].'",'.$jst[1].')',strlen('sprintf("'.$jst[0].'"'));
} catch (Exception $e) {
$this->runResult['errors'][] = 'Failed formattingstring for rule \''.$rule['name'].'\'. PHP threw following error: '.$e->getMessage();
return;
}
$rule['justification'] = $str;
}
break;
}
$this->runResult[$type][] = $rule;
}
// Runs a code expression, replacing variable names with their respective values
// ignoreUntil: if > 0, it doesn't replace any variables until that string position, but still evaluates the whole expr
function ruleExprEvaluate($expr, $ignoreUntil) {
if($ignoreUntil > 0) {
$exprIgnore = substr($expr,0,$ignoreUntil);
$expr = substr($expr,$ignoreUntil);
}
$expr = preg_replace('/fired\s*\(\s*(\'|")(.*)\1\s*\)/Uie','1',$expr); //isset($this->runResult[\'fired\']
$expr = preg_replace('/\b(\w+)\b/e','isset($this->variables[\'\1\']) ? (!is_numeric($this->variables[\'\1\']) ? \'"\'.$this->variables[\'\1\'].\'"\' : $this->variables[\'\1\']) : \'\1\'', $expr);
if($ignoreUntil > 0){
$expr = $exprIgnore . $expr;
}
$value = 0;
$err = 0;
ob_start();
eval('$value = '.$expr.';');
$err = ob_get_contents();
ob_end_clean();
if($err) throw new Exception(strip_tags($err) . '<br />Executed code: $value = '.$expr.';');
return $value;
}
function parseRulesFile() {
$file = file('libraries/advisory_rules.txt');
$errors = array();
$rules = array();
$ruleSyntax = array('name','formula','test','issue','recommendation','justification');
$numRules = count($ruleSyntax);
$numLines = count($file);
$j = -1;
$ruleLine = -1;
for ($i = 0; $i<$numLines; $i++) {
$line = $file[$i];
if($line[0] == '#' || $line[0] == "\n") continue;
// Reading new rule
if(substr($line, 0, 4) == 'rule') {
if($ruleLine > 0) { $errors[] = 'Invalid rule declaration on line '.($i+1). ', expected line '.$ruleSyntax[$ruleLine++].' of previous rule' ; continue; }
$ruleLine = 1;
if(preg_match("/rule\s'(.*)'( \[(.*)\])?$/",$line,$match)) {
$j++;
$rules[$j] = array( 'name' => $match[1]);
if(isset($match[3])) $rules[$j]['precondition'] = $match[3];
} else {
$errors[] = 'Invalid rule declaration on line '.($i+1);
}
continue;
} else {
if($ruleLine == -1) $errors[] = 'Unexpected characters on line '.($i+1);
}
// Reading rule lines
if($ruleLine > 0) {
if(!isset($line[0])) continue; // Empty lines are ok
// Non tabbed lines are not
if($line[0] != "\t") { $errors[] = 'Unexpected character on line '.($i+1).'. Expected tab, but found \''.$line[0].'\''; continue; }
$rules[$j][$ruleSyntax[$ruleLine++]] = chop(substr($line,1));
}
// Rule complete
if($ruleLine == $numRules) {
$ruleLine = -1;
}
}
return array('rules' => $rules, 'errors' => $errors);
}
}
function PMA_bytime($num, $precision)
{
$per = '';
if ($num >= 1) { # per second
$per = "per second";
}
elseif ($num*60 >= 1) { # per minute
$num = $num*60;
$per = "per minute";
}
elseif ($num*60*60 >=1 ) { # per hour
$num = $num*60*60;
$per = "per hour";
}
else {
$num = $num*60*60*24;
$per = "per day";
}
$num = round($num, $precision);
if($num == 0) $num = '<'.pow(10,-$precision);
return "$num $per";
}
?>

View File

@ -0,0 +1,427 @@
# phpMyAdmin Advisory rules file
# Use only UNIX style newlines
# This file is being parsed by advisor.lib.php, which should handle syntax errors correctly.
# However, PHP Warnings and the like are being consumed by the phpMyAdmin error handler, so those won't show up
# E.g.: Justification line is empty because you used an unescape percent sign, sprintf() returns an empty string and no warning/error is shown
#
# Rule Syntax:
# 'rule' identifier[the name of the rule] eexpr [an optional precondition]
# expr [variable or value calculation used for the test]
# expr [test, if evaluted to 'true' it fires the rule. Use 'value' to insert the calculated value (without quotes)]
# string [the issue (what is the problem?)]
# string [the recommendation (how do i fix it?)]
# formatted-string '|' comma-seperated-expr [the justification (result of the calculated value / why did this rule fire?)]
# comma-seperated-expr: expr(,expr)*
# eexpr: [expr] - expr enclosed in []
# expr: a php code literal with extras:
# - variable names are replaced with their respective values
# - fired('name of rule') is replaced with true/false when given rule has been fired. Note however that this is a very simple rules engine. Rules are only checked in sequential order as they are written down here. If given rule has not been checked yet, fired() will always evaluate to false
# - 'value' is replaced with the calculated value. If it is a string, it will be put within single quotes
# - other than that you may use any php function, initialized variable or constant
#
# identifier: A string enclosed in single quotes
# string: A quoteless string, may contain HTML. Variable names enclosed in curly braces are replaced with links to directly edit this variable. e.g. {tmp_table_size}
# formatted-string: You may use classic php sprintf() string formatting here, the arguments must be appended after a trailing pipe (|) as mentioned in above syntax
# percent signs (%) are automatically escaped (%%) in the following cases: When followed by a space, dot or comma and at the end of the line)
#
# Comments start with #
#
# Queries
rule 'Uptime below one day'
Uptime
value < 86400
Uptime is less than 1 day, performance tuning may not be accurate.
To have more accurate averages it is recommended to let the server run for longer than a day before running this analyzer
The uptime is only %s | PMA_timespanFormat(Uptime)
rule 'Questions below 1,000'
Questions
value < 1000
Fewer than 1,000 questions have been run against this server. The recommendations may not be accurate.
Let the server run for a longer time until it has executed a greater amount of queries.
Current amount of Questions: %s | Questions
rule '% slow queries' [Questions > 0]
Slow_queries / Questions * 100
value >= 5
There is a lot of slow queries compared to the overall amount of Queries.
You might want to increase {long_query_time} or optimize the queries listed in the slow query log
The slow query rate should be below 5%, your value is %s%. | round(value,2)
rule 'slow query rate' [Questions > 0]
(Slow_queries / Questions * 100) / Uptime
value * 60 * 60 > 1
There is a high percentage of slow queries compared to the server uptime.
You might want to increase {long_query_time} or optimize the queries listed in the slow query log
You have a slow query rate of %s per hour, you should have less than 1% per hour. | PMA_bytime(value,2)
rule 'Long query time'
long_query_time
value >= 10
long_query_time is set to 10 seconds or more, thus only slow queries that take above 10 seconds are logged.
It is suggested to set {long_query_time} to a lower value, depending on your enviroment. Usually a value of 1-5 seconds is suggested.
long_query_time is currently set to %ss. | value
rule 'Slow query logging'
log_slow_queries
value == 'OFF'
The slow query log is disabled.
Enable slow query logging by setting {log_slow_queries} to 'ON'. This will help troubleshooting badly performing queries.
log_slow_queries is set to 'OFF'
#
# versions
rule 'Release Series'
version
!PMA_DRIZZLE && substr(value,0,3) != "5.1"
The MySQL server version is less than 5.1.
You should upgrade, as MySQL 5.1 has improved performance, and MySQL 5.5 even more so.
Current version: %s | value
rule 'Minor Version'
version
!PMA_DRIZZLE && substr(value,4,2) < 30
Version less than 5.1.30 (the first GA release of 5.1).
You should upgrade, as recent versions of MySQL 5.1 have improved performance and MySQL 5.5 even more so.
Current version: %s | value
rule 'Distribution'
version_comment
preg_match('/source/i',value)
Version is compiled from source, not a MySQL official binary. If you did not compile from source, you may be using a package modified by a distribution.
The MySQL manual only is accurate for official MySQL binaries, not any package distributions (such as RedHat, Debian/Ubuntu etc).
'source' found in version_comment
rule 'Distribution'
version_comment
preg_match('/percona/i',value)
The MySQL manual only is accurate for official MySQL binaries.
Percona documentation is at http://www.percona.com/docs/wiki/
'percona' found in version_comment
rule 'MySQL Architecture'
system_memory
value > 3072 && !preg_match('/64/',version_compile_machine)
MySQL is not compiled as a 64-bit package, though your memory capacity is above 3 GiB.
MySQL might not be able to access all of your memory. You might want to consider installing the 64-bit version of MySQL.
Available memory on this host: %s | implode(' ',PMA_formatByteDown(value*1024*1024, 2, 2))
#
# Query cache
# Lame: 'ON' == 0 is true, so you need to compare 'ON' == '0'
rule 'Query cache disabled'
query_cache_size
value == 0 || query_cache_type == 'OFF' || query_cache_type == '0'
The query cache is not enabled.
The query cache is known to greatly improve performance if configured correctly. Enable it by setting {query_cache_size} to a 2 digit MiB value and setting {query_cache_type} to 'ON'
query_cache_size is set to 0 or query_cache_type is set to 'OFF'
rule 'Query cache efficiency (%)' [Com_select + Qcache_hits > 0 && !fired('Query cache disabled')]
Qcache_hits / (Com_select + Qcache_hits) * 100
value < 20
Query cache not running efficiently, it has a low hit rate.
Consider increasing {query_cache_limit}.
The current query cache hit rate of %s% is below 20% | round(value,1)
rule 'Query Cache usage' [!fired('Query cache disabled')]
100 - Qcache_free_memory / query_cache_size * 100
value < 80
Less than 80% of the query cache is being utilized.
This might be caused by {query_cache_limit} being too low. Flushing the query cache might help as well.
The current ratio of free query cache memory to total query cache size is %s%. It should be above 80% | round(value,1)
rule 'Query cache fragmentation' [!fired('Query cache disabled')]
Qcache_free_blocks / (Qcache_total_blocks / 2) * 100
value > 20
The query cache is considerably fragmented.
Severe fragmentation is likely to (further) increase Qcache_lowmem_prunes. This might be caused by many Query cache low memory prunes due to {query_cache_size} being too small. For a immediate but short lived fix you can flush the query cache (might lock the query cache for a long time). Carefully adjusting {query_cache_min_res_unit} to a lower value might help too, e.g. you can set it to the average size of your queries in the cache using this formula: (query_cache_size - qcache_free_memory) / qcache_queries_in_cache
The cache is currently fragmented by %s% , with 100% fragmentation meaning that the query cache is an alternating pattern of free and used blocks. This value should be below 20%. | round(value,1)
rule 'Query cache low memory prunes' [Qcache_inserts > 0 && !fired('Query cache disabled')]
Qcache_lowmem_prunes / Qcache_inserts * 100
value > 0.1
Cached queries are removed due to low query cache memory from the query cache.
You might want to increase {query_cache_size}, however keep in mind that the overhead of maintaining the cache is likely to increase with its size, so do this in small increments and monitor the results.
The ratio of removed queries to inserted queries is %s%. The lower this value is, the better (This rules firing limit: 0.1%) | round(value,1)
rule 'Query cache max size' [!fired('Query cache disabled')]
query_cache_size
value > 1024 * 128
The query cache size is above 128 MiB. Big query caches may cause significant overhead that is required to maintain the cache.
Depending on your enviroment, it might be performance increasing to reduce this value.
Current query cache size: %s | implode(' ',PMA_formatByteDown(value, 2, 2))
rule 'Query cache min result size' [!fired('Query cache disabled')]
value == 1024*1024
query_cache_limit
The max size of the result set in the query cache is the default of 1 MiB.
Changing {query_cache_limit} (usually by increasing) may increase efficiency. This variable determines the maximum size a query result may have to be inserted into the query cache. If there are many query results above 1 MiB that are well cacheable (many reads, little writes) then increasing {query_cache_limit} will increase efficiency. Whereas in the case of many query results being above 1 MiB that are not very well cacheable (often invalidated due to table updates) increasing {query_cache_limit} might reduce efficiency.
query_cache_limit is set to 1 MiB
#
# Sorts
rule '% sorts that cause temporary tales' [Sort_scan + Sort_range > 0]
Sort_merge_passes / (Sort_scan + Sort_range) * 100
value > 10
Too many sorts are causing temporary tables.
Consider increasing sort_buffer_size and/or read_rnd_buffer_size, depending on your system memory limits
%s% of all sorts cause temporary tables, this value should be lower than 10%. | round(value,1)
rule 'rate of sorts that cause temporary tables'
Sort_merge_passes / Uptime
value * 60 * 60 > 1
Too many sorts are causing temporary tables.
Consider increasing sort_buffer_size and/or read_rnd_buffer_size, depending on your system memory limits
Temporary tables average: %s, this value should be less than 1 per hour. | PMA_bytime(value,2)
rule 'Sort rows'
Sort_rows / Uptime
value * 60 >= 1
There are lots of rows being sorted.
While there is nothing wrong with a high amount of row sorting, you might want to make sure that the queries which require a lot of sorting use indexed fields in the ORDER BY clause, as this will result in much faster sorting
Sorted rows average: %s | PMA_bytime(value,2)
# Joins, scans
rule 'rate of joins without indexes'
(Select_range_check + Select_scan + Select_full_join) / Uptime
value * 60 * 60 > 1
There are too many joins without indexes.
This means that joins are doing full table scans. Adding indexes for the fields being used in the join conditions will greatly speed up table joins
Table joins average: %s, this value should be less than 1 per hour | PMA_bytime(value,2)
rule 'rate of reading first index entry'
Handler_read_first / Uptime
value * 60 * 60 > 1
The rate of reading the first index entry is high.
This usually indicates frequent full index scans. Full index scans are faster than table scans but require lots of cpu cycles in big tables, if those tables that have or had high volumes of UPDATEs and DELETEs, running 'OPTIMIZE TABLE' might reduce the amount of and/or speed up full index scans. Other than that full index scans can only be reduced by rewriting queries.
Index scans average: %s, this value should be less than 1 per hour | PMA_bytime(value,2)
rule 'rate of reading fixed position'
Handler_read_rnd / Uptime
value * 60 * 60 > 1
The rate of reading data from a fixed position is high.
This indicates many queries need to sort results and/or do a full table scan, including join queries that do not use indexes. Add indexes where applicable.
Rate of reading fixed position average: %s, this value should be less than 1 per hour | PMA_bytime(value,2)
rule 'rate of reading next table row'
Handler_read_rnd_next / Uptime
value * 60 * 60 > 1
The rate of reading the next table row is high.
This indicates many queries are doing full table scans. Add indexes where applicable.
Rate of reading next table row: %s, this value should be less than 1 per hour | PMA_bytime(value,2)
# temp tables
rule 'tmp_table_size vs. max_heap_table_size'
tmp_table_size - max_heap_table_size
value !=0
tmp_table_size and max_heap_table_size are not the same.
If you have deliberatly changed one of either: The server uses the lower value of either to determine the maximum size of in-memory tables. So if you wish to increse the in-memory table limit you will have to increase the other value as well.
Current values are tmp_table_size: %s, max_heap_table_size: %s | implode(' ',PMA_formatByteDown(tmp_table_size, 2, 2)), implode(' ',PMA_formatByteDown(max_heap_table_size, 2, 2))
rule '% temp disk tables' [Created_tmp_tables + Created_tmp_disk_tables > 0]
Created_tmp_disk_tables / (Created_tmp_tables + Created_tmp_disk_tables) * 100
value > 25
Many temporary tables are being written to disk instead of being kept in memory.
Increasing {max_heap_table_size} and {tmp_table_size} might help. However some temporary tables are always being written to disk, independent of the value of these variables. To elminiate these you will have to rewrite your queries to avoid those conditions (Within a temprorary table: Presence of a BLOB or TEXT column or presence of a column bigger than 512 bytes) as mentioned in the beginning of an <a href="http://www.facebook.com/note.php?note_id=10150111255065841&comments">Article by the Pythian Group</a>
%s% of all temporary tables are being written to disk, this value should be below 25% | round(value,1)
rule 'temp disk rate'
Created_tmp_disk_tables / Uptime
value * 60 * 60 > 1
Many temporary tables are being written to disk instead of being kept in memory.
Increasing {max_heap_table_size} and {tmp_table_size} might help. However some temporary tables are always being written to disk, independent of the value of these variables. To elminiate these you will have to rewrite your queries to avoid those conditions (Within a temprorary table: Presence of a BLOB or TEXT column or presence of a column bigger than 512 bytes) as mentioned in in the <a href="http://dev.mysql.com/doc/refman/5.0/en/internal-temporary-tables.html">MySQL Documentation</a>
Rate of temporay tables being written to disk: %s, this value should be less than 1 per hour | PMA_bytime(value,2)
# I couldn't find any source on the internet that suggests a direct relation between high counts of temporary tables and any of these variables.
# Several independent Blog entries suggest (http://ronaldbradford.com/blog/more-on-understanding-sort_buffer_size-2010-05-10/ and http://www.xaprb.com/blog/2010/05/09/how-to-tune-mysqls-sort_buffer_size/)
# that sort_buffer_size should be left as it is. And increasing read_buffer_size is only suggested when there are a lot of
# table scans (http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_read_buffer_size and other sources) though
# setting it too high is bad too (http://www.mysqlperformanceblog.com/2007/09/17/mysql-what-read_buffer_size-value-is-optimal/).
#rule 'temp table rate'
# Created_tmp_tables / Uptime
# value * 60 * 60 > 1
# Many intermediate temporary tables are being created.
# This may be caused by queries under certain conditions as mentioned in the <a href="http://dev.mysql.com/doc/refman/5.0/en/internal-temporary-tables.html">MySQL Documentation</a>. Consider increasing {sort_buffer_size} (sorting), {read_rnd_buffer_size} (random read buffer, ie, post-sort), {read_buffer_size} (sequential scan).
#
# MyISAM index cache
rule 'MyISAM key buffer size'
key_buffer_size
value == 0
Key buffer is not initialized. No MyISAM indexes will be cached.
Set {key_buffer_size} depending on the size of your MyISAM indexes. 64M is a good start.
key_buffer_size is 0
rule 'max % MyISAM key buffer ever used' [key_buffer_size > 0]
Key_blocks_used * key_cache_block_size / key_buffer_size * 100
value < 95
MyISAM key buffer (index cache) % used is low.
You may need to decrease the size of {key_buffer_size}, re-examine your tables to see if indexes have been removed, or examine queries and expectations about what indexes are being used.
max % MyISAM key buffer ever used: %s, this value should be above 95% | round(value,1)
# Don't fire if above rule fired - we don't need the same advice twice
rule '% MyISAM key buffer used' [key_buffer_size > 0 && !fired('max % MyISAM key buffer ever used')]
( 1 - Key_blocks_unused * key_cache_block_size / key_buffer_size) * 100
value < 95
MyISAM key buffer (index cache) % used is low.
You may need to decrease the size of {key_buffer_size}, re-examine your tables to see if indexes have been removed, or examine queries and expectations about what indexes are being used.
% MyISAM key buffer used: %s, this value should be above 95% | round(value,1)
rule '% index reads from memory' [Key_read_requests > 0]
100 - (Key_reads / Key_read_requests * 100)
value < 95
The % of indexes that use the MyISAM key buffer is low.
You may need to increase {key_buffer_size}.
Index reads from memory: %s%, this value should be above 95% | round(value,1)
#
# other caches
rule 'rate of table open'
Opened_tables / Uptime
value*60*60 > 10
The rate of opening tables is high.
Opening tables requires disk I/O which is costly. Increasing {table_open_cache} might avoid this.
Opened table rate: %s, this value should be less than 10 per hour | PMA_bytime(value,2)
rule '% open files'
Open_files / open_files_limit * 100
value > 85
The number of open files is approaching the max number of open files. You may get a "Too many open files" error.
Consider increasing {open_files_limit}, and check the error log when restarting after changing open_files_limit.
The number of opened files is at %s% of the limit. It should be below 85% | round(value,1)
rule 'rate of open files'
Open_files / Uptime
value * 60 * 60 > 5
The rate of opening files is high.
Consider increasing {open_files_limit}, and check the error log when restarting after changing open_files_limit.
Opened files rate: %s, this value should be less than 5 per hour | PMA_bytime(value,2)
rule 'Immediate table locks %' [Table_locks_waited + Table_locks_immediate > 0]
Table_locks_immediate / (Table_locks_waited + Table_locks_immediate) * 100
value < 95
Too many table locks were not granted immediately.
Optimize queries and/or use InnoDB to reduce lock wait.
Immediate table locks: %s%, this value should be above 95% | round(value,1)
rule 'Table lock wait rate'
Table_locks_waited / Uptime
value * 60 * 60 > 1
Too many table locks were not granted immediately.
Optimize queries and/or use InnoDB to reduce lock wait.
Table lock wait rate: %s, this value should be less than 1 per hour | PMA_bytime(value,2)
rule 'thread cache'
thread_cache_size
value < 1
Thread cache is disabled, resulting in more overhead from new connections to MySQL.
Enable the thread cache by setting {thread_cache_size} > 0.
The thread cache is set to 0
rule 'thread cache hit rate %' [thread_cache_size > 0]
100 - Threads_created / Connections
value < 80
Thread cache is not efficient.
Increase {thread_cache_size}.
Thread cache hitrate: %s%, this value should be above 80% | round(value,1)
rule 'Threads that are slow to launch' [slow_launch_time > 0]
Slow_launch_threads
value > 0
There are too many threads that are slow to launch.
This generally happens in case of general system overload as it is pretty simple operations. You might want to monitor your system load carefully.
%s thread(s) took longer than %s seconds to start, it should be 0 | value, slow_launch_time
rule 'Slow launch time'
slow_launch_time
value > 2
Slow_launch_threads is above 2s
Set slow_launch_time to 1s or 2s to correctly count threads that are slow to launch
slow_launch_time is set to %s | value
#
#Connections
rule '% connections used'
Max_used_connections / max_connections * 100
value > 80
The maximum amount of used connnections is getting close to the value of max_connections.
Increase max_connections, or decrease wait_timeout so that connections that do not close database handlers properly get killed sooner. Make sure the code closes database handlers properly.
Max_used_connections is at %s% of max_connections, it should be below 80% | round(value,1)
rule '% aborted connections'
Aborted_connects / Connections * 100
value > 1
Too many connections are aborted.
Connections are usually aborted when they cannot be authorized. <a href="http://www.mysqlperformanceblog.com/2008/08/23/how-to-track-down-the-source-of-aborted_connects/">This article</a> might help you track down the source.
%s% of all connections are aborted. This value should be below 1% | round(value,1)
rule 'rate of aborted connections'
Aborted_connects / Uptime
value * 60 * 60 > 1
Too many connections are aborted
Connections are usually aborted when they cannot be authorized. <a href="http://www.mysqlperformanceblog.com/2008/08/23/how-to-track-down-the-source-of-aborted_connects/">This article</a> might help you track down the source.
Aborted connections rate is at %s, this value should be less than 1 per hour | PMA_bytime(value,2)
rule '% aborted clients'
Aborted_clients / Connections * 100
value > 2
Too many clients are aborted.
Clients are usually aborted when they did not close their connection to MySQL properly. This can be due to network issues or code not closing a database handler properly. Check your network and code.
%s% of all clients are aborted. This value should be below 2% | round(value,1)
rule 'rate of aborted clients'
Aborted_clients / Uptime
value * 60 * 60 > 1
Too many clients are aborted.
Clients are usually aborted when they did not close their connection to MySQL properly. This can be due to network issues or code not closing a database handler properly. Check your network and code.
Aborted client rate is at %s, this value should be less than 1 per hour | PMA_bytime(value,2)
#
# InnoDB
rule 'Is InnoDB disabled?'
have_innodb
value != "YES"
You do not have InnoDB enabled.
InnoDB is usually the better choice for table engines.
have_innodb is set to 'value'
rule '% InnoDB log size' [innodb_buffer_pool_size > 0]
innodb_log_file_size / innodb_buffer_pool_size * 100
value < 20
The InnoDB log file size is not an appropriate size, in relation to the InnoDB buffer pool.
Especiallay one a system with a lot of writes to InnoDB tables you shoud set innodb_log_file_size to 25% of {innodb_buffer_pool_size}. However the bigger this value, the longer the recovery time will be when database crashes, so this value should not be set much higher than 256 MiB. Please note however that you cannot simply change the value of this variable. You need to shutdown the server, remove the InnoDB log files, set the new value in my.cnf, start the server, then check the error logs if everything went fine. See also <a href="http://mysqldatabaseadministration.blogspot.com/2007/01/increase-innodblogfilesize-proper-way.html">this blog entry</a>
Your InnoDB log size is at %s% in relation to the InnoDB buffer pool size, it should not be below 20% | round(value,1)
rule 'Max InnoDB log size' [innodb_buffer_pool_size > 0 && innodb_log_file_size / innodb_buffer_pool_size * 100 < 30]
innodb_log_file_size / (1024 * 1024)
value >= 128
The InnoDB log file size is inadequately large.
It is usually sufficient to set innodb_log_file_size to 25% of the size of {innodb_buffer_pool_size}. A very innodb_log_file_size slows down the recovery time after a database crash considerably. See also <a href="http://www.mysqlperformanceblog.com/2006/07/03/choosing-proper-innodb_log_file_size/">this Article</a>. You need to shutdown the server, remove the InnoDB log files, set the new value in my.cnf, start the server, then check the error logs if everything went fine. See also <a href="http://mysqldatabaseadministration.blogspot.com/2007/01/increase-innodblogfilesize-proper-way.html">this blog entry</a>
Your absolute InnoD log size is %s MiB | round(value,1)
rule 'InnoDB buffer pool size' [system_memory > 0]
innodb_buffer_pool_size / system_memory * 100
value < 60
Your InnoDB buffer pool is fairly small.
The InnoDB buffer pool has a profound impact on perfomance for InnoDB tables. Assign all your remaining memory to this buffer. For database servers that use solely InnoDB as storage engine and have no other services (e.g. a web server) running, you may set this as high as 80% of your available memory. If that is not the case, you need to carefully assess the memory consumption of your other services and non-InnoDB-Tables and set this variable accordingly. If it is set too high, your system will start swapping, which decreases performance significantly. See also <a href="http://www.mysqlperformanceblog.com/2007/11/03/choosing-innodb_buffer_pool_size/">this article</a>
You are currently using %s% of your memory for the InnoDB buffer pool. This rule fires if you are assigning less than 60%, however this might be perfectly adequate for your system if you don't have much InnoDB tables or other services running on the same machine.
#
# other
rule 'MyISAM concurrent inserts'
concurrent_insert
value == 0
Enable concurrent_insert by setting it to 1
Setting {concurrent_insert} to 1 reduces contention between readers and writers for a given table. See also <a href="http://dev.mysql.com/doc/refman/5.0/en/concurrent-inserts.html">MySQL Documentation</a>
concurrent_insert is set to 0
# INSERT DELAYED USAGE
#Delayed_errors 0
#Delayed_insert_threads 0
#Delayed_writes 0
#Not_flushed_delayed_rows

View File

@ -81,7 +81,8 @@ if (function_exists('mcrypt_encrypt')) {
*
* @access public
*/
function PMA_get_blowfish_secret() {
function PMA_get_blowfish_secret()
{
if (empty($GLOBALS['cfg']['blowfish_secret'])) {
if (empty($_SESSION['auto_blowfish_secret'])) {
// this returns 23 characters

View File

@ -18,7 +18,8 @@
*
* @access public
*/
function PMA_auth() {
function PMA_auth()
{
unset($_SESSION['LAST_SIGNON_URL']);
if (empty($GLOBALS['cfg']['Server']['SignonURL'])) {
PMA_fatalError('You must set SignonURL!');

View File

@ -228,15 +228,25 @@ function PMA_BS_GetVariables()
return $BS_Variables;
}
//========================
//========================
/**
* Retrieves and shows PBMS error.
*
* @return nothing
*/
function PMA_BS_ReportPBMSError($msg)
{
$tmp_err = pbms_error();
PMA_showMessage(__('PBMS error') . " $msg $tmp_err");
}
//------------
/**
* Tries to connect to PBMS server.
*
* @param string $db_name Database name
* @param bool $quiet Whether to report errors
*
* @return bool Connection status.
*/
function PMA_do_connect($db_name, $quiet)
{
$PMA_Config = $GLOBALS['PMA_Config'];
@ -266,17 +276,24 @@ function PMA_do_connect($db_name, $quiet)
return true;
}
//------------
/**
* Disconnects from PBMS server.
*
* @return nothing
*/
function PMA_do_disconnect()
{
pbms_close();
}
//------------
/**
* checks whether the BLOB reference looks valid
* Checks whether the BLOB reference looks valid
*
*/
* @param string $bs_reference BLOB reference
* @param string $db_name Database name
*
* @return bool True on success.
*/
function PMA_BS_IsPBMSReference($bs_reference, $db_name)
{
if (PMA_cacheGet('skip_blobstreaming', true)) {
@ -312,7 +329,7 @@ function PMA_BS_CreateReferenceLink($bs_reference, $db_name)
$content_type = pbms_get_metadata_value("Content-Type");
if ($content_type == false) {
$br = trim($bs_reference);
PMA_BS_ReportPBMSError("PMA_BS_CreateReferenceLink('$br', '$db_name'): " . __('get BLOB Content-Type failed'));
PMA_BS_ReportPBMSError("PMA_BS_CreateReferenceLink('$br', '$db_name'): " . __('PBMS get BLOB Content-Type failed'));
}
PMA_do_disconnect();
@ -357,11 +374,12 @@ function PMA_BS_CreateReferenceLink($bs_reference, $db_name)
return $output;
}
//------------
// In the future there may be server variables to turn on/off PBMS
// BLOB streaming on a per table or database basis. So in anticipation of this
// PMA_BS_IsTablePBMSEnabled() passes in the table and database name even though
// they are not currently needed.
/**
* In the future there may be server variables to turn on/off PBMS
* BLOB streaming on a per table or database basis. So in anticipation of this
* PMA_BS_IsTablePBMSEnabled() passes in the table and database name even though
* they are not currently needed.
*/
function PMA_BS_IsTablePBMSEnabled($db_name, $tbl_name, $tbl_type)
{
if (PMA_cacheGet('skip_blobstreaming', true)) {

View File

@ -13,7 +13,8 @@ if (! defined('PHPMYADMIN')) {
*
* @return array
*/
function PMA_getColumnOrder() {
function PMA_getColumnOrder()
{
$column_order['DEFAULT_COLLATION_NAME'] = array(
'disp_name' => __('Collation'),
@ -70,7 +71,8 @@ function PMA_getColumnOrder() {
*
* @return array $column_order, $out
*/
function PMA_buildHtmlForDb($current, $is_superuser, $checkall, $url_query, $column_order, $replication_types, $replication_info) {
function PMA_buildHtmlForDb($current, $is_superuser, $checkall, $url_query, $column_order, $replication_types, $replication_info)
{
$out = '';
if ($is_superuser || $GLOBALS['cfg']['AllowUserDropDatabase']) {

View File

@ -67,7 +67,8 @@ if ($PMA_recoding_engine == PMA_CHARSET_ICONV_AIX) {
* @access public
*
*/
function PMA_convert_string($src_charset, $dest_charset, $what) {
function PMA_convert_string($src_charset, $dest_charset, $what)
{
if ($src_charset == $dest_charset) {
return $what;
}

View File

@ -552,7 +552,7 @@ $_REQUEST['js_frame'] = PMA_ifSetOr($_REQUEST['js_frame'], '');
* @global array $js_include
*/
$GLOBALS['js_include'] = array();
$GLOBALS['js_include'][] = 'jquery/jquery-1.6.1.js';
$GLOBALS['js_include'][] = 'jquery/jquery-1.6.2.js';
$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
$GLOBALS['js_include'][] = 'update-location.js';

View File

@ -6,12 +6,32 @@
* @package phpMyAdmin
*/
/**
* Detects which function to use for PMA_pow.
*
* @return string Function name.
*/
function PMA_detect_pow()
{
if (function_exists('bcpow')) {
// BCMath Arbitrary Precision Mathematics Function
return 'bcpow';
} elseif (function_exists('gmp_pow')) {
// GMP Function
return 'gmp_pow';
} else {
// PHP function
return 'pow';
}
}
/**
* Exponential expression / raise number into power
*
* @param string $base base to raise
* @param string $exp exponent to use
* @param mixed $use_function pow function to use, or false for auto-detect
*
* @return mixed string or float
*/
function PMA_pow($base, $exp, $use_function = false)
@ -19,16 +39,7 @@ function PMA_pow($base, $exp, $use_function = false)
static $pow_function = null;
if (null == $pow_function) {
if (function_exists('bcpow')) {
// BCMath Arbitrary Precision Mathematics Function
$pow_function = 'bcpow';
} elseif (function_exists('gmp_pow')) {
// GMP Function
$pow_function = 'gmp_pow';
} else {
// PHP function
$pow_function = 'pow';
}
$pow_function = PMA_detect_pow();
}
if (! $use_function) {
@ -64,34 +75,21 @@ function PMA_pow($base, $exp, $use_function = false)
*
* @param string $icon name of icon file
* @param string $alternate alternate text
* @param boolean $container include in container
* @param boolean $force_text whether to force alternate text to be displayed
* @param boolean $noSprite If true, the image source will be not replaced with a CSS Sprite
*
* @return html img tag
*/
function PMA_getIcon($icon, $alternate = '', $container = false, $force_text = false, $noSprite = false)
function PMA_getIcon($icon, $alternate = '', $force_text = false, $noSprite = false)
{
$include_icon = false;
$include_text = false;
$include_box = false;
// $cfg['PropertiesIconic'] is true or both
$include_icon = ($GLOBALS['cfg']['PropertiesIconic'] !== false);
// $cfg['PropertiesIconic'] is false or both
// OR we have no $include_icon
$include_text = ($force_text || true !== $GLOBALS['cfg']['PropertiesIconic']);
$alternate = htmlspecialchars($alternate);
$button = '';
if ($GLOBALS['cfg']['PropertiesIconic']) {
$include_icon = true;
}
if ($force_text || true !== $GLOBALS['cfg']['PropertiesIconic']) {
// $cfg['PropertiesIconic'] is false or both
// OR we have no $include_icon
$include_text = true;
}
if ($include_text && $include_icon && $container) {
// we have icon, text and request for container
$include_box = true;
}
// Always use a span (we rely on this in js/sql.js)
$button .= '<span class="nowrap">';
@ -123,6 +121,7 @@ function PMA_getIcon($icon, $alternate = '', $container = false, $force_text = f
* Displays the maximum size for an upload
*
* @param integer $max_upload_size the size
*
* @return string the message
*
* @access public
@ -140,6 +139,7 @@ function PMA_displayMaximumUploadSize($max_upload_size)
* the maximum size for upload
*
* @param integer $max_size the size
*
* @return string the INPUT field
*
* @access public
@ -195,6 +195,7 @@ function PMA_sqlAddSlashes($a_string = '', $is_like = false, $crlf = false, $php
* Note: This function does not escape backslashes!
*
* @param string $name the string to escape
*
* @return string the escaped string
*
* @access public
@ -212,7 +213,9 @@ function PMA_escape_mysql_wildcards($name)
* Note: This function does not unescape backslashes!
*
* @param string $name the string to escape
*
* @return string the escaped string
*
* @access public
*/
function PMA_unescape_mysql_wildcards($name)
@ -230,6 +233,7 @@ function PMA_unescape_mysql_wildcards($name)
*
* @param string $quoted_string string to remove quotes from
* @param string $quote type of quote to remove
*
* @return string unqoted string
*/
function PMA_unQuote($quoted_string, $quote = null)
@ -263,6 +267,7 @@ function PMA_unQuote($quoted_string, $quote = null)
* @todo move into PMA_Sql
* @param mixed $parsed_sql pre-parsed SQL structure
* @param string $unparsed_sql raw SQL string
*
* @return string the formatted sql
*
* @global array the configuration array
@ -410,11 +415,13 @@ function PMA_showMySQLDocu($chapter, $link, $big_icon = false, $anchor = '', $ju
* Displays a link to the phpMyAdmin documentation
*
* @param string $anchor anchor in documentation
*
* @return string the html link
*
* @access public
*/
function PMA_showDocu($anchor) {
function PMA_showDocu($anchor)
{
if ($GLOBALS['cfg']['ReplaceHelpImg']) {
return '<a href="Documentation.html#' . $anchor . '" target="documentation"><img class="icon ic_b_help_s" src="themes/dot.gif" alt="' . __('Documentation') . '" title="' . __('Documentation') . '" /></a>';
} else {
@ -426,11 +433,13 @@ function PMA_showDocu($anchor) {
* Displays a link to the PHP documentation
*
* @param string $target anchor in documentation
*
* @return string the html link
*
* @access public
*/
function PMA_showPHPDocu($target) {
function PMA_showPHPDocu($target)
{
$url = PMA_getPHPDocLink($target);
if ($GLOBALS['cfg']['ReplaceHelpImg']) {
@ -446,7 +455,9 @@ function PMA_showPHPDocu($target) {
* @param string $message the error message
* @param bool $bbcode
* @param string $type
*
* @return string html code for a footnote marker
*
* @access public
*/
function PMA_showHint($message, $bbcode = false, $type = 'notice')
@ -638,6 +649,7 @@ function PMA_mysqlDie($error_message = '', $the_query = '',
* @param string $tables name of tables
* @param integer $limit_offset list offset
* @param int|bool $limit_count max tables to return
*
* @return array (recursive) grouped table list
*/
function PMA_getTableList($db, $tables = null, $limit_offset = 0, $limit_count = false)
@ -768,7 +780,9 @@ function PMA_getTableList($db, $tables = null, $limit_offset = 0, $limit_count =
* or array of it
* @param boolean $do_it a flag to bypass this function (used by dump
* functions)
*
* @return mixed the "backquoted" database, table or field name
*
* @access public
*/
function PMA_backquote($a_name, $do_it = true)
@ -862,7 +876,9 @@ if (!$jsonly)
* @param string $sql_query the query to display
* @param string $type the type (level) of the message
* @param boolean $is_view is this a message after a VIEW operation?
*
* @return string
*
* @access public
*/
function PMA_showMessage($message, $sql_query = null, $type = 'notice', $is_view = false)
@ -1218,6 +1234,7 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice', $is_view
* Verifies if current MySQL server supports profiling
*
* @access public
*
* @return boolean whether profiling is supported
*/
function PMA_profilingSupported()
@ -1303,6 +1320,7 @@ function PMA_formatByteDown($value, $limes = 6, $comma = 0)
* Changes thousands and decimal separators to locale specific values.
*
* @param $value
*
* @return string
*/
function PMA_localizeNumber($value)
@ -1416,6 +1434,7 @@ function PMA_formatNumber($value, $digits_left = 3, $digits_right = 0, $only_dow
* Returns the number of bytes when a formatted size is given
*
* @param string $formatted_size the size expression (for example 8MB)
*
* @return integer The numerical part of the expression (for example 8)
*/
function PMA_extractValueFromFormattedSize($formatted_size)
@ -1437,6 +1456,7 @@ function PMA_extractValueFromFormattedSize($formatted_size)
*
* @param string $timestamp the current timestamp
* @param string $format format
*
* @return string the formatted date
*
* @access public
@ -1506,7 +1526,9 @@ function PMA_localisedDate($timestamp = -1, $format = '')
*
* @param array $tab array with all options
* @param array $url_params
*
* @return string html code for one tab, a link if valid otherwise a span
*
* @access public
*/
function PMA_generate_html_tab($tab, $url_params = array(), $base_dir='')
@ -1605,6 +1627,7 @@ function PMA_generate_html_tab($tab, $url_params = array(), $base_dir='')
*
* @param array $tabs one element per tab
* @param string $url_params
*
* @return string html-code for tab-navigation
*/
function PMA_generate_html_tabs($tabs, $url_params, $base_dir='')
@ -1781,6 +1804,7 @@ function PMA_timespanFormat($seconds)
* @param string $Separator The Separator (defaults to "<br />\n")
*
* @access public
*
* @return string The flipped string
*/
function PMA_flipstring($string, $Separator = "<br />\n")
@ -1882,6 +1906,7 @@ function PMA_checkParameters($params, $die = true, $request = true)
* @param boolean $force_unique generate condition only on pk or unique
*
* @access public
*
* @return array the calculated condition and whether condition is unique
*/
function PMA_getUniqueCondition($handle, $fields_cnt, $fields_meta, $row, $force_unique=false)
@ -2058,6 +2083,7 @@ function PMA_buttonOrImage($button_name, $button_class, $image_name, $text,
* @param string $prompt The prompt to display (sometimes empty)
*
* @return string
*
* @access public
*/
function PMA_pageselector($rows, $pageNow = 1, $nbTotalPage = 1,
@ -2153,7 +2179,8 @@ function PMA_pageselector($rows, $pageNow = 1, $nbTotalPage = 1,
*
* @access public
*/
function PMA_listNavigator($count, $pos, $_url_params, $script, $frame, $max_count) {
function PMA_listNavigator($count, $pos, $_url_params, $script, $frame, $max_count)
{
if ($max_count < $count) {
echo 'frame_navigation' == $frame ? '<div id="navidbpageselector">' . "\n" : '';
@ -2231,7 +2258,9 @@ function PMA_listNavigator($count, $pos, $_url_params, $script, $frame, $max_cou
* $user_dir = PMA_userDir('/var/pma_tmp/%u/'); // '/var/pma_tmp/root/'
*
* </code>
*
* @param string $dir with wildcard for user
*
* @return string per user directory
*/
function PMA_userDir($dir)
@ -2248,6 +2277,7 @@ function PMA_userDir($dir)
* returns html code for db link to default db page
*
* @param string $database
*
* @return string html link to default db page
*/
function PMA_getDbLink($database = null)
@ -2286,11 +2316,12 @@ function PMA_externalBug($functionality, $component, $minimum_version, $bugref)
* Generates and echoes an HTML checkbox
*
* @param string $html_field_name the checkbox HTML field
* @param string $label
* @param boolean $checked is it initially checked?
* @param boolean $onclick should it submit the form on click?
* @param string $label label for checkbox
* @param boolean $checked is it initially checked?
* @param boolean $onclick should it submit the form on click?
*/
function PMA_display_html_checkbox($html_field_name, $label, $checked, $onclick) {
function PMA_display_html_checkbox($html_field_name, $label, $checked, $onclick)
{
echo '<input type="checkbox" name="' . $html_field_name . '" id="' . $html_field_name . '"' . ($checked ? ' checked="checked"' : '') . ($onclick ? ' onclick="this.form.submit();"' : '') . ' /><label for="' . $html_field_name . '">' . $label . '</label>';
}
@ -2299,13 +2330,14 @@ function PMA_display_html_checkbox($html_field_name, $label, $checked, $onclick)
* Generates and echoes a set of radio HTML fields
*
* @param string $html_field_name the radio HTML field
* @param array $choices the choices values and labels
* @param string $checked_choice the choice to check by default
* @param boolean $line_break whether to add an HTML line break after a choice
* @param boolean $escape_label whether to use htmlspecialchars() on label
* @param string $class enclose each choice with a div of this class
* @param array $choices the choices values and labels
* @param string $checked_choice the choice to check by default
* @param boolean $line_break whether to add an HTML line break after a choice
* @param boolean $escape_label whether to use htmlspecialchars() on label
* @param string $class enclose each choice with a div of this class
*/
function PMA_display_html_radio($html_field_name, $choices, $checked_choice = '', $line_break = true, $escape_label = true, $class='') {
function PMA_display_html_radio($html_field_name, $choices, $checked_choice = '', $line_break = true, $escape_label = true, $class='')
{
foreach ($choices as $choice_value => $choice_label) {
if (! empty($class)) {
echo '<div class="' . $class . '">';
@ -2336,6 +2368,7 @@ function PMA_display_html_radio($html_field_name, $choices, $checked_choice = ''
* @param string $id id of the select element; can be different in case
* the dropdown is present more than once on the page
* @return string
*
* @todo support titles
*/
function PMA_generate_html_dropdown($select_name, $choices, $active_choice, $id)
@ -2463,7 +2496,8 @@ function PMA_toggleButton($action, $select_name, $options, $callback)
/**
* Clears cache content which needs to be refreshed on user change.
*/
function PMA_clearUserCache() {
function PMA_clearUserCache()
{
PMA_cacheUnset('is_superuser', true);
}
@ -2472,6 +2506,7 @@ function PMA_clearUserCache() {
*
* @param string $var
* @param int|true $server
*
* @return boolean
*/
function PMA_cacheExists($var, $server = 0)
@ -2487,6 +2522,7 @@ function PMA_cacheExists($var, $server = 0)
*
* @param string $var
* @param int|true $server
*
* @return mixed
*/
function PMA_cacheGet($var, $server = 0)
@ -2507,6 +2543,7 @@ function PMA_cacheGet($var, $server = 0)
* @param string $var
* @param mixed $val
* @param int|true $server
*
* @return mixed
*/
function PMA_cacheSet($var, $val = null, $server = 0)
@ -2538,9 +2575,11 @@ function PMA_cacheUnset($var, $server = 0)
*
* @param numeric $value coming from a BIT field
* @param integer $length
*
* @return string the printable value
*/
function PMA_printable_bit_value($value, $length) {
function PMA_printable_bit_value($value, $length)
{
$printable = '';
for ($i = 0, $len_ceiled = ceil($length / 8); $i < $len_ceiled; $i++) {
$printable .= sprintf('%08d', decbin(ord(substr($value, $i, 1))));
@ -2553,9 +2592,11 @@ function PMA_printable_bit_value($value, $length) {
* Verifies whether the value contains a non-printable character
*
* @param string $value
*
* @return boolean
*/
function PMA_contains_nonprintable_ascii($value) {
function PMA_contains_nonprintable_ascii($value)
{
return preg_match('@[^[:print:]]@', $value);
}
@ -2564,9 +2605,11 @@ function PMA_contains_nonprintable_ascii($value) {
* for example, b'010' becomes 010
*
* @param string $bit_default_value
*
* @return string the converted value
*/
function PMA_convert_bit_default_value($bit_default_value) {
function PMA_convert_bit_default_value($bit_default_value)
{
return strtr($bit_default_value, array("b" => "", "'" => ""));
}
@ -2574,17 +2617,19 @@ function PMA_convert_bit_default_value($bit_default_value) {
* Extracts the various parts from a field type spec
*
* @param string $fieldspec
*
* @return array associative array containing type, spec_in_brackets
* and possibly enum_set_values (another array)
*/
function PMA_extractFieldSpec($fieldspec) {
function PMA_extractFieldSpec($fieldspec)
{
$first_bracket_pos = strpos($fieldspec, '(');
if ($first_bracket_pos) {
$spec_in_brackets = chop(substr($fieldspec, $first_bracket_pos + 1, (strrpos($fieldspec, ')') - $first_bracket_pos - 1)));
// convert to lowercase just to be sure
$type = strtolower(chop(substr($fieldspec, 0, $first_bracket_pos)));
} else {
$type = $fieldspec;
$type = strtolower($fieldspec);
$spec_in_brackets = '';
}
@ -2635,14 +2680,52 @@ function PMA_extractFieldSpec($fieldspec) {
// Increment character index
$index++;
} // end while
$printtype = $type . '(' . str_replace("','", "', '", $spec_in_brackets) . ')';
$binary = false;
$unsigned = false;
$zerofill = false;
} else {
$enum_set_values = array();
/* Create printable type name */
$printtype = strtolower($fieldspec);
// strip the "BINARY" attribute, except if we find "BINARY(" because
// this would be a BINARY or VARBINARY field type
if (!preg_match('@binary[\(]@', $printtype)) {
$binary = strpos($printtype, 'blob') !== false || strpos($printtype, 'binary') !== false;
$printtype = preg_replace('@binary@', '', $printtype);
} else {
$binary = false;
}
$printtype = preg_replace('@zerofill@', '', $printtype, -1, $zerofill_cnt);
$zerofill = ($zerofill_cnt > 0);
$printtype = preg_replace('@unsigned@', '', $printtype, -1, $unsigned_cnt);
$unsigned = ($unsigned_cnt > 0);
$printtype = trim($printtype);
}
$attribute = ' ';
if ($binary) {
$attribute = 'BINARY';
}
if ($unsigned) {
$attribute = 'UNSIGNED';
}
if ($zerofill) {
$attribute = 'UNSIGNED ZEROFILL';
}
return array(
'type' => $type,
'spec_in_brackets' => $spec_in_brackets,
'enum_set_values' => $enum_set_values
'enum_set_values' => $enum_set_values,
'print_type' => $printtype,
'binary' => $binary,
'unsigned' => $unsigned,
'zerofill' => $zerofill,
'attribute' => $attribute,
);
}
@ -2650,9 +2733,11 @@ function PMA_extractFieldSpec($fieldspec) {
* Verifies if this table's engine supports foreign keys
*
* @param string $engine
*
* @return boolean
*/
function PMA_foreignkey_supported($engine) {
function PMA_foreignkey_supported($engine)
{
$engine = strtoupper($engine);
if ('INNODB' == $engine || 'PBXT' == $engine) {
return true;
@ -2665,9 +2750,11 @@ function PMA_foreignkey_supported($engine) {
* Replaces some characters by a displayable equivalent
*
* @param string $content
*
* @return string the content with characters replaced
*/
function PMA_replace_binary_contents($content) {
function PMA_replace_binary_contents($content)
{
$result = str_replace("\x00", '\0', $content);
$result = str_replace("\x08", '\b', $result);
$result = str_replace("\x0a", '\n', $result);
@ -2705,10 +2792,12 @@ function PMA_asWKT($data, $includeSRID = false) {
* If the string starts with a \r\n pair (0x0d0a) add an extra \n
*
* @param string $string
*
* @return string with the chars replaced
*/
function PMA_duplicateFirstNewline($string) {
function PMA_duplicateFirstNewline($string)
{
$first_occurence = strpos($string, "\r\n");
if ($first_occurence === 0) {
$string = "\n".$string;
@ -2722,9 +2811,11 @@ function PMA_duplicateFirstNewline($string) {
*
* @param string $target a valid value for $cfg['LeftDefaultTabTable'], $cfg['DefaultTabTable']
* or $cfg['DefaultTabDatabase']
*
* @return array
*/
function PMA_getTitleForTarget($target) {
function PMA_getTitleForTarget($target)
{
$mapping = array(
// Values for $cfg['DefaultTabTable']
'tbl_structure.php' => __('Structure'),
@ -2748,9 +2839,11 @@ function PMA_getTitleForTarget($target) {
* @param string $string Text where to do expansion.
* @param function $escape Function to call for escaping variable values.
* @param array $updates Array with overrides for default parameters (obtained from GLOBALS).
*
* @return string
*/
function PMA_expandUserString($string, $escape = null, $updates = array()) {
function PMA_expandUserString($string, $escape = null, $updates = array())
{
/* Content */
$vars['http_host'] = PMA_getenv('HTTP_HOST') ? PMA_getenv('HTTP_HOST') : '';
$vars['server_name'] = $GLOBALS['cfg']['Server']['host'];
@ -2792,9 +2885,7 @@ function PMA_expandUserString($string, $escape = null, $updates = array()) {
/* Fetch fields list if required */
if (strpos($string, '@FIELDS@') !== false) {
$fields_list = PMA_DBI_fetch_result(
'SHOW COLUMNS FROM ' . PMA_backquote($GLOBALS['db'])
. '.' . PMA_backquote($GLOBALS['table']));
$fields_list = PMA_DBI_get_columns($GLOBALS['db'], $GLOBALS['table']);
$field_names = array();
foreach ($fields_list as $field) {
@ -2868,7 +2959,8 @@ function PMA_ajaxResponse($message, $success = true, $extra_data = array())
*
* @param $max_upload_size
*/
function PMA_browseUploadFile($max_upload_size) {
function PMA_browseUploadFile($max_upload_size)
{
echo '<label for="radio_import_file">' . __("Browse your computer:") . '</label>';
echo '<div id="upload_form_status" style="display: none;"></div>';
echo '<div id="upload_form_status_info" style="display: none;"></div>';
@ -2884,7 +2976,8 @@ function PMA_browseUploadFile($max_upload_size) {
* @param $import_list
* @param $uploaddir
*/
function PMA_selectUploadFile($import_list, $uploaddir) {
function PMA_selectUploadFile($import_list, $uploaddir)
{
echo '<label for="radio_local_import_file">' . sprintf(__("Select from the web server upload directory <b>%s</b>:"), htmlspecialchars(PMA_userDir($uploaddir))) . '</label>';
$extensions = '';
foreach ($import_list as $key => $val) {
@ -2914,26 +3007,27 @@ function PMA_selectUploadFile($import_list, $uploaddir) {
*
* @return array the action titles
*/
function PMA_buildActionTitles() {
function PMA_buildActionTitles()
{
$titles = array();
$titles['Browse'] = PMA_getIcon('b_browse.png', __('Browse'), true);
$titles['NoBrowse'] = PMA_getIcon('bd_browse.png', __('Browse'), true);
$titles['Search'] = PMA_getIcon('b_select.png', __('Search'), true);
$titles['NoSearch'] = PMA_getIcon('bd_select.png', __('Search'), true);
$titles['Insert'] = PMA_getIcon('b_insrow.png', __('Insert'), true);
$titles['NoInsert'] = PMA_getIcon('bd_insrow.png', __('Insert'), true);
$titles['Structure'] = PMA_getIcon('b_props.png', __('Structure'), true);
$titles['Drop'] = PMA_getIcon('b_drop.png', __('Drop'), true);
$titles['NoDrop'] = PMA_getIcon('bd_drop.png', __('Drop'), true);
$titles['Empty'] = PMA_getIcon('b_empty.png', __('Empty'), true);
$titles['NoEmpty'] = PMA_getIcon('bd_empty.png', __('Empty'), true);
$titles['Edit'] = PMA_getIcon('b_edit.png', __('Edit'), true);
$titles['NoEdit'] = PMA_getIcon('bd_edit.png', __('Edit'), true);
$titles['Export'] = PMA_getIcon('b_export.png', __('Export'), true);
$titles['NoExport'] = PMA_getIcon('bd_export.png', __('Export'), true);
$titles['Execute'] = PMA_getIcon('b_nextpage.png', __('Execute'), true);
$titles['NoExecute'] = PMA_getIcon('bd_nextpage.png', __('Execute'), true);
$titles['Browse'] = PMA_getIcon('b_browse.png', __('Browse'));
$titles['NoBrowse'] = PMA_getIcon('bd_browse.png', __('Browse'));
$titles['Search'] = PMA_getIcon('b_select.png', __('Search'));
$titles['NoSearch'] = PMA_getIcon('bd_select.png', __('Search'));
$titles['Insert'] = PMA_getIcon('b_insrow.png', __('Insert'));
$titles['NoInsert'] = PMA_getIcon('bd_insrow.png', __('Insert'));
$titles['Structure'] = PMA_getIcon('b_props.png', __('Structure'));
$titles['Drop'] = PMA_getIcon('b_drop.png', __('Drop'));
$titles['NoDrop'] = PMA_getIcon('bd_drop.png', __('Drop'));
$titles['Empty'] = PMA_getIcon('b_empty.png', __('Empty'));
$titles['NoEmpty'] = PMA_getIcon('bd_empty.png', __('Empty'));
$titles['Edit'] = PMA_getIcon('b_edit.png', __('Edit'));
$titles['NoEdit'] = PMA_getIcon('bd_edit.png', __('Edit'));
$titles['Export'] = PMA_getIcon('b_export.png', __('Export'));
$titles['NoExport'] = PMA_getIcon('bd_export.png', __('Export'));
$titles['Execute'] = PMA_getIcon('b_nextpage.png', __('Execute'));
$titles['NoExecute'] = PMA_getIcon('bd_nextpage.png', __('Execute'));
return $titles;
}
@ -3271,6 +3365,7 @@ function PMA_getFunctionsForField($field, $insert_mode)
* string, db name where to also check for privileges
* @param mixed $tbl null, to only check global privileges
* string, db name where to also check for privileges
*
* @return bool
*/
function PMA_currentUserHasPrivilege($priv, $db = null, $tbl = null)

View File

@ -224,7 +224,7 @@ function PMA_fatalError($error_message, $message_args = null)
}
require('./libraries/error.inc.php');
if (!defined('TESTSUITE')) {
exit;
}
@ -239,7 +239,8 @@ function PMA_fatalError($error_message, $message_args = null)
*
* @access public
*/
function PMA_getPHPDocLink($target) {
function PMA_getPHPDocLink($target)
{
/* l10n: Language to use for PHP documentation, please use only languages which do exist in official documentation. */
$lang = _pgettext('PHP documentation language', 'en');
@ -463,7 +464,8 @@ function PMA_checkPageValidity(&$page, $whitelist)
* @param string $var_name variable name
* @return string value of $var or empty string
*/
function PMA_getenv($var_name) {
function PMA_getenv($var_name)
{
if (isset($_SERVER[$var_name])) {
return $_SERVER[$var_name];
} elseif (isset($_ENV[$var_name])) {
@ -537,6 +539,53 @@ function PMA_sendHeaderLocation($uri)
}
}
/**
* Outputs headers to prevent caching in browser (and on the way).
*
* @return nothing
*/
function PMA_no_cache_header()
{
header('Expires: ' . date(DATE_RFC1123)); // rfc2616 - Section 14.21
header('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
if (PMA_USR_BROWSER_AGENT == 'IE') {
/* FIXME: Why is this speecial case for IE needed? */
header('Pragma: public');
} else {
header('Pragma: no-cache'); // HTTP/1.0
// test case: exporting a database into a .gz file with Safari
// would produce files not having the current time
// (added this header for Safari but should not harm other browsers)
header('Last-Modified: ' . date(DATE_RFC1123));
}
}
/**
* Sends header indicating file download.
*
* @param string $filename Filename to include in headers.
* @param string $mimetype MIME type to include in headers.
* @param int $length Length of content (optional)
* @param bool $no_cache Whether to include no-caching headers.
*
* @return nothing
*/
function PMA_download_header($filename, $mimetype, $length = 0, $no_cache = true)
{
if ($no_cache) {
PMA_no_cache_header();
}
header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename="' . $filename . '"');
header('Content-Type: ' . $mimetype);
header('Content-Transfer-Encoding: binary');
if ($length > 0) {
header('Content-Length: ' . $length);
}
}
/**
* Returns value of an element in $array given by $path.
* $path is a string describing position of an element in an associative array,
@ -629,7 +678,8 @@ function PMA_array_remove($path, &$array)
*
* @return string URL for a link.
*/
function PMA_linkURL($url) {
function PMA_linkURL($url)
{
if (!preg_match('#^https?://#', $url) || defined('PMA_SETUP')) {
return $url;
} else {
@ -646,7 +696,8 @@ function PMA_linkURL($url) {
*
* @return string HTML code for javascript inclusion.
*/
function PMA_includeJS($url) {
function PMA_includeJS($url)
{
if (strpos($url, '?') === false) {
return '<script src="./js/' . $url . '?ts=' . filemtime('./js/' . $url) . '" type="text/javascript"></script>' . "\n";
} else {

View File

@ -24,7 +24,8 @@ define('PMA_DBI_GETVAR_GLOBAL', 2);
*
* @param string $extension mysql extension to check
*/
function PMA_DBI_checkMysqlExtension($extension = 'mysql') {
function PMA_DBI_checkMysqlExtension($extension = 'mysql')
{
if (! function_exists($extension . '_connect')) {
return false;
}
@ -67,9 +68,16 @@ if (! PMA_DBI_checkMysqlExtension($GLOBALS['cfg']['Server']['extension'])) {
require_once './libraries/dbi/' . $GLOBALS['cfg']['Server']['extension'] . '.dbi.lib.php';
/**
* Common Functions
* runs a query
*
* @param string $query SQL query to execte
* @param mixed $link optional database link to use
* @param int $options optional query options
* @param bool $cache_affected_rows whether to cache affected rows
* @return mixed
*/
function PMA_DBI_query($query, $link = null, $options = 0, $cache_affected_rows = true) {
function PMA_DBI_query($query, $link = null, $options = 0, $cache_affected_rows = true)
{
$res = PMA_DBI_try_query($query, $link, $options, $cache_affected_rows)
or PMA_mysqlDie(PMA_DBI_getError($link), $query);
return $res;
@ -78,9 +86,10 @@ function PMA_DBI_query($query, $link = null, $options = 0, $cache_affected_rows
/**
* runs a query and returns the result
*
* @param string $query query to run
* @param string $query query to run
* @param resource $link mysql link resource
* @param integer $options
* @param integer $options
* @param bool $cache_affected_rows
* @return mixed
*/
function PMA_DBI_try_query($query, $link = null, $options = 0, $cache_affected_rows = true)
@ -148,7 +157,8 @@ function PMA_DBI_try_query($query, $link = null, $options = 0, $cache_affected_r
* @param string $message
* @return string $message
*/
function PMA_DBI_convert_message($message) {
function PMA_DBI_convert_message($message)
{
// latin always last!
$encodings = array(
'japanese' => 'EUC-JP', //'ujis',
@ -237,9 +247,6 @@ function PMA_DBI_get_tables($database, $link = null)
* @return integer a value representing whether $a should be before $b in the
* sorted array or not
*
* @global string the column the array shall be sorted by
* @global string the sorting order ('ASC' or 'DESC')
*
* @access private
*/
function PMA_usort_comparison_callback($a, $b)
@ -276,9 +283,9 @@ function PMA_usort_comparison_callback($a, $b)
*
* @todo move into PMA_Table
* @param string $database database
* @param string|false $table table
* @param string|bool $table table or false
* @param boolean|string $tbl_is_group $table is a table group
* @param resource $link mysql link
* @param mixed $link mysql link
* @param integer $limit_offset zero-based offset for the count
* @param boolean|integer $limit_count number of tables to return
* @param string $sort_by table attribute to sort by
@ -438,12 +445,12 @@ function PMA_DBI_get_tables_full($database, $table = false, $tbl_is_group = fals
}
if (! isset($each_tables[$table_name]['Type'])
&& isset($each_tables[$table_name]['Engine'])) {
&& isset($each_tables[$table_name]['Engine'])) {
// pma BC, same parts of PMA still uses 'Type'
$each_tables[$table_name]['Type']
=& $each_tables[$table_name]['Engine'];
} elseif (! isset($each_tables[$table_name]['Engine'])
&& isset($each_tables[$table_name]['Type'])) {
&& isset($each_tables[$table_name]['Type'])) {
// old MySQL reports Type, newer MySQL reports Engine
$each_tables[$table_name]['Engine']
=& $each_tables[$table_name]['Type'];
@ -837,13 +844,13 @@ function PMA_DBI_get_columns($database, $table, $full = false, $link = null)
'SHOW ' . ($full ? 'FULL' : '') . ' COLUMNS
FROM ' . PMA_backquote($database) . '.' . PMA_backquote($table),
'Field', null, $link);
if (! is_array($fields) || count($fields) < 1) {
return false;
if (! is_array($fields) || count($fields) == 0) {
return null;
}
return $fields;
}
/**
/**
* returns value of given mysql server variable
*
* @param string $var mysql server variable name
@ -851,8 +858,6 @@ function PMA_DBI_get_columns($database, $table, $full = false, $link = null)
* @param mixed $link mysql link resource|object
* @return mixed value for mysql server variable
*/
function PMA_DBI_get_variable($var, $type = PMA_DBI_GETVAR_SESSION, $link = null)
{
if ($link === null) {
@ -878,8 +883,8 @@ function PMA_DBI_get_variable($var, $type = PMA_DBI_GETVAR_SESSION, $link = null
}
/**
* Function called just after a connection to the MySQL database server has been established
* It sets the connection collation, and determins the version of MySQL which is running.
* Function called just after a connection to the MySQL database server has been established
* It sets the connection collation, and determins the version of MySQL which is running.
*
* @param mixed $link mysql link resource|object
* @param boolean $is_controluser
@ -948,7 +953,8 @@ function PMA_DBI_postConnect($link, $is_controluser = false)
* @return mixed value of first field in first row from result
* or false if not found
*/
function PMA_DBI_fetch_value($result, $row_number = 0, $field = 0, $link = null, $options = 0) {
function PMA_DBI_fetch_value($result, $row_number = 0, $field = 0, $link = null, $options = 0)
{
$value = false;
if (is_string($result)) {
@ -1002,7 +1008,8 @@ function PMA_DBI_fetch_value($result, $row_number = 0, $field = 0, $link = null,
* @return array|boolean first row from result
* or false if result is empty
*/
function PMA_DBI_fetch_single_row($result, $type = 'ASSOC', $link = null, $options = 0) {
function PMA_DBI_fetch_single_row($result, $type = 'ASSOC', $link = null, $options = 0)
{
if (is_string($result)) {
$result = PMA_DBI_try_query($result, $link, $options | PMA_DBI_QUERY_STORE, false);
}

View File

@ -53,7 +53,7 @@ function PMA_DBI_real_connect($server, $user, $password, $client_flags, $persist
/**
* connects to the database server
*
*
* @param string $user mysql user name
* @param string $password mysql user password
* @param bool $is_controluser
@ -188,7 +188,8 @@ function PMA_DBI_fetch_array($result)
* @param resource $result
* @return array
*/
function PMA_DBI_fetch_assoc($result) {
function PMA_DBI_fetch_assoc($result)
{
return mysql_fetch_array($result, MYSQL_ASSOC);
}
@ -232,7 +233,8 @@ function PMA_DBI_free_result($result)
*
* @return bool false
*/
function PMA_DBI_more_results() {
function PMA_DBI_more_results()
{
// N.B.: PHP's 'mysql' extension does not support
// multi_queries so this function will always
// return false. Use the 'mysqli' extension, if
@ -245,7 +247,8 @@ function PMA_DBI_more_results() {
*
* @return boo false
*/
function PMA_DBI_next_result() {
function PMA_DBI_next_result()
{
// N.B.: PHP's 'mysql' extension does not support
// multi_queries so this function will always
// return false. Use the 'mysqli' extension, if

View File

@ -256,7 +256,8 @@ function PMA_DBI_free_result($result)
* @param mysqli $link the mysqli object
* @return bool true or false
*/
function PMA_DBI_more_results($link = null) {
function PMA_DBI_more_results($link = null)
{
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
@ -273,7 +274,8 @@ function PMA_DBI_more_results($link = null) {
* @param mysqli $link the mysqli object
* @return bool true or false
*/
function PMA_DBI_next_result($link = null) {
function PMA_DBI_next_result($link = null)
{
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
@ -286,7 +288,7 @@ function PMA_DBI_next_result($link = null) {
/**
* Returns a string representing the type of connection used
*
*
* @param resource $link mysql link
* @return string type of connection used
*/

View File

@ -15,13 +15,15 @@ $cfgRelation = PMA_getRelationsParam();
require_once './libraries/file_listing.php';
require_once './libraries/plugin_interface.lib.php';
function PMA_exportCheckboxCheck($str) {
function PMA_exportCheckboxCheck($str)
{
if (isset($GLOBALS['cfg']['Export'][$str]) && $GLOBALS['cfg']['Export'][$str]) {
echo ' checked="checked"';
}
}
function PMA_exportIsActive($what, $val) {
function PMA_exportIsActive($what, $val)
{
if (isset($GLOBALS['cfg']['Export'][$what]) && $GLOBALS['cfg']['Export'][$what] == $val) {
echo ' checked="checked"';
}

View File

@ -11,7 +11,7 @@ if (!defined('PHPMYADMIN')) {
/**
* constant for differenciating array in $_SESSION variable
*/
$SESSION_KEY = '__upload_status';
$SESSION_KEY = '__upload_status';
/**
* sets default plugin for handling the import process
@ -35,12 +35,12 @@ $plugins = array(
// select available plugin
foreach ($plugins as $plugin) {
$check = "PMA_import_" . $plugin . "Check";
if ($check()) {
$_SESSION[$SESSION_KEY]["handler"] = $plugin;
include_once("import/upload/" . $plugin . ".php");
break;
}
}
}
/**
@ -48,7 +48,8 @@ foreach ($plugins as $plugin) {
*
* @return true if APC extension is available and if rfc1867 is enabled, false if it is not
*/
function PMA_import_apcCheck() {
function PMA_import_apcCheck()
{
if (! extension_loaded('apc') || ! function_exists('apc_fetch') || ! function_exists('getallheaders')) {
return false;
}
@ -57,10 +58,11 @@ function PMA_import_apcCheck() {
/**
* Checks if UploadProgress bar extension is available.
*
*
* @return true if UploadProgress extension is available, false if it is not
*/
function PMA_import_uploadprogressCheck() {
function PMA_import_uploadprogressCheck()
{
if (! function_exists("uploadprogress_get_info") || ! function_exists('getallheaders')) {
return false;
}
@ -68,19 +70,21 @@ function PMA_import_uploadprogressCheck() {
}
/**
* Default plugin for handling import. If no other plugin is available, noplugin is used.
*
* @return true
*
* @return true
*/
function PMA_import_nopluginCheck() {
function PMA_import_nopluginCheck()
{
return true;
}
/**
* The function outputs json encoded status of uploaded. It uses PMA_getUploadStatus, which is defined in plugin's file.
*
*
* @param $id - ID of transfer, usually $upload_id from display_import_ajax.lib.php
*/
function PMA_importAjaxStatus($id) {
function PMA_importAjaxStatus($id)
{
header('Content-type: application/json');
echo json_encode(PMA_getUploadStatus($id));
}

View File

@ -17,7 +17,8 @@ if (! defined('PHPMYADMIN')) {
* @return the sorted array
* @access private
*/
function PMA_language_cmp(&$a, &$b) {
function PMA_language_cmp(&$a, &$b)
{
return (strcmp($a[1], $b[1]));
} // end of the 'PMA_language_cmp()' function
@ -26,7 +27,8 @@ function PMA_language_cmp(&$a, &$b) {
*
* @access public
*/
function PMA_select_language($use_fieldset = false, $show_doc = true) {
function PMA_select_language($use_fieldset = false, $show_doc = true)
{
global $cfg, $lang;
?>

View File

@ -28,12 +28,12 @@ require_once './libraries/Index.class.php';
* the "display printable view" option.
* Of course '0'/'1' means the feature won't/will be enabled.
*
* @param string &$the_disp_mode the synthetic value for display_mode (see a few
* lines above for explanations)
* @param integer &$the_total the total number of rows returned by the SQL query
* without any programmatically appended "LIMIT" clause
* (just a copy of $unlim_num_rows if it exists, else
* computed inside this function)
* @param string &$the_disp_mode the synthetic value for display_mode (see a few
* lines above for explanations)
* @param integer &$the_total the total number of rows returned by the SQL query
* without any programmatically appended "LIMIT" clause
* (just a copy of $unlim_num_rows if it exists, else
* computed inside this function)
*
* @return array an array with explicit indexes for all the display
* elements
@ -80,7 +80,9 @@ function PMA_setDisplayMode(&$the_disp_mode, &$the_total)
$do_display['bkm_form'] = (string) '0';
$do_display['text_btn'] = (string) '0';
$do_display['pview_lnk'] = (string) '0';
} elseif ($GLOBALS['is_count'] || $GLOBALS['is_analyse'] || $GLOBALS['is_maint'] || $GLOBALS['is_explain']) {
} elseif ($GLOBALS['is_count'] || $GLOBALS['is_analyse']
|| $GLOBALS['is_maint'] || $GLOBALS['is_explain']
) {
// 2.1 Statement is a "SELECT COUNT", a
// "CHECK/ANALYZE/REPAIR/OPTIMIZE", an "EXPLAIN" one or
// contains a "PROC ANALYSE" part
@ -131,7 +133,8 @@ function PMA_setDisplayMode(&$the_disp_mode, &$the_total)
|| $do_display['ins_row'] != '0');
// 2.3.2 Displays edit/delete/sort/insert links?
if ($is_link
&& ($fields_meta[$i]->table == '' || $fields_meta[$i]->table != $prev_table)) {
&& ($fields_meta[$i]->table == '' || $fields_meta[$i]->table != $prev_table)
) {
$do_display['edit_lnk'] = 'nn'; // don't display links
$do_display['del_lnk'] = 'nn';
/**
@ -203,7 +206,6 @@ function PMA_isSelect()
/**
* Displays a navigation button
*
*
* @param string $caption iconic caption for button
* @param string $title text for button
* @param integer $pos position for next query
@ -212,6 +214,8 @@ function PMA_isSelect()
* @param string $input_for_real_end optional hidden field for special treatment
* @param string $onclick optional onclick clause
*
* @return nothing
*
* @global string $db the database name
* @global string $table the table name
* @global string $goto the URL to go back in case of errors
@ -220,7 +224,8 @@ function PMA_isSelect()
*
* @see PMA_displayTableNavigation()
*/
function PMA_displayTableNavigationOneButton($caption, $title, $pos, $html_sql_query, $onsubmit = '', $input_for_real_end = '', $onclick = '') {
function PMA_displayTableNavigationOneButton($caption, $title, $pos, $html_sql_query, $onsubmit = '', $input_for_real_end = '', $onclick = '')
{
global $db, $table, $goto;
@ -256,6 +261,8 @@ function PMA_displayTableNavigationOneButton($caption, $title, $pos, $html_sql_q
* @param string $sql_query the URL-encoded query
* @param string $id_for_direction_dropdown the id for the direction dropdown
*
* @return nothing
*
* @global string $db the database name
* @global string $table the table name
* @global string $goto the URL to go back in case of errors
@ -407,8 +414,10 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, $id_for_di
echo '<input id="col_visib" type="hidden" value="' . implode(',', $col_visib) . '" />';
}
// generate table create time
echo '<input id="table_create_time" type="hidden" value="' .
PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], 'Create_time') . '" />';
if (! PMA_Table::isView($GLOBALS['table'], $GLOBALS['db'])) {
echo '<input id="table_create_time" type="hidden" value="' .
PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], 'Create_time') . '" />';
}
}
// generate hints
echo '<input id="col_order_hint" type="hidden" value="' . __('Drag to reorder') . '" />';
@ -463,10 +472,13 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, $id_for_di
/**
* Displays the headers of the results table
*
* @param array which elements to display
* @param array the list of fields properties
* @param integer the total number of fields returned by the SQL query
* @param array the analyzed query
* @param array &$is_display which elements to display
* @param array &$fields_meta the list of fields properties
* @param integer $fields_cnt the total number of fields returned by the SQL query
* @param array $analyzed_sql the analyzed query
* @param string $sort_expression sort expression
* @param string $sort_expression_nodirection sort expression without direction
* @param string $sort_direction sort direction
*
* @return boolean $clause_is_unique
*
@ -842,8 +854,10 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
// the orgname member does not exist for all MySQL versions
// but if found, it's the one on which to sort
$name_to_use_in_sort = $fields_meta[$i]->name;
$is_orgname = false;
if (isset($fields_meta[$i]->orgname) && strlen($fields_meta[$i]->orgname)) {
$name_to_use_in_sort = $fields_meta[$i]->orgname;
$is_orgname = true;
}
// $name_to_use_in_sort might contain a space due to
// formatting of function expressions like "COUNT(name )"
@ -870,12 +884,15 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
// 2.1.3 Check the field name for a bracket.
// If it contains one, it's probably a function column
// like 'COUNT(`field`)'
if (strpos($name_to_use_in_sort, '(') !== false) {
// It still might be a column name of a view. See bug #3383711
// Check is_orgname.
if (strpos($name_to_use_in_sort, '(') !== false && ! $is_orgname) {
$sort_order = ' ORDER BY ' . $name_to_use_in_sort . ' ';
} else {
$sort_order = ' ORDER BY ' . $sort_tbl . PMA_backquote($name_to_use_in_sort) . ' ';
}
unset($name_to_use_in_sort);
unset($is_orgname);
// 2.1.4 Do define the sorting URL
if (! $is_in_sort) {
@ -1060,25 +1077,27 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
/**
* Prepares the display for a value
*
* @param string $class
* @param string $condition_field
* @param string $value
* @param string $class class of table cell
* @param bool $condition_field whether to add CSS class condition
* @param string $value value to display
*
* @return string the td
*/
function PMA_buildValueDisplay($class, $condition_field, $value) {
function PMA_buildValueDisplay($class, $condition_field, $value)
{
return '<td align="left"' . ' class="' . $class . ($condition_field ? ' condition' : '') . '">' . $value . '</td>';
}
/**
* Prepares the display for a null value
*
* @param string $class
* @param string $condition_field
* @param string $class class of table cell
* @param bool $condition_field whether to add CSS class condition
*
* @return string the td
*/
function PMA_buildNullDisplay($class, $condition_field) {
function PMA_buildNullDisplay($class, $condition_field)
{
// the null class is needed for inline editing
return '<td align="right"' . ' class="' . $class . ($condition_field ? ' condition' : '') . ' null"><i>NULL</i></td>';
}
@ -1086,13 +1105,15 @@ function PMA_buildNullDisplay($class, $condition_field) {
/**
* Prepares the display for an empty value
*
* @param string $class
* @param string $condition_field
* @param string $align
* @param string $class class of table cell
* @param bool $condition_field whether to add CSS class condition
* @param object $meta the meta-information about this field
* @param string $align cell allignment
*
* @return string the td
*/
function PMA_buildEmptyDisplay($class, $condition_field, $meta, $align = '') {
function PMA_buildEmptyDisplay($class, $condition_field, $meta, $align = '')
{
$nowrap = ' nowrap';
return '<td ' . $align . ' class="' . PMA_addClass($class, $condition_field, $meta, $nowrap) . '"></td>';
}
@ -1100,17 +1121,18 @@ function PMA_buildEmptyDisplay($class, $condition_field, $meta, $align = '') {
/**
* Adds the relavant classes.
*
* @param string $class
* @param string $condition_field
* @param object $meta the meta-information about this field
* @param string $nowrap
* @param bool $is_field_truncated
* @param string $transform_function
* @param string $default_function
* @param string $class class of table cell
* @param bool $condition_field whether to add CSS class condition
* @param object $meta the meta-information about this field
* @param string $nowrap avoid wrapping
* @param bool $is_field_truncated is field truncated (display ...)
* @param string $transform_function transformation function
* @param string $default_function default transformation function
*
* @return string the list of classes
*/
function PMA_addClass($class, $condition_field, $meta, $nowrap, $is_field_truncated = false, $transform_function = '', $default_function = '') {
function PMA_addClass($class, $condition_field, $meta, $nowrap, $is_field_truncated = false, $transform_function = '', $default_function = '')
{
// Define classes to be added to this data field based on the type of data
$enum_class = '';
if (strpos($meta->flags, 'enum') !== false) {
@ -1142,31 +1164,32 @@ function PMA_addClass($class, $condition_field, $meta, $nowrap, $is_field_trunca
/**
* Displays the body of the results table
*
* @param integer the link id associated to the query which results have
* to be displayed
* @param array which elements to display
* @param array the list of relations
* @param array the analyzed query
* @param integer &$dt_result the link id associated to the query which results have
* to be displayed
* @param array &$is_display which elements to display
* @param array $map the list of relations
* @param array $analyzed_sql the analyzed query
*
* @return boolean always true
*
* @global string $db the database name
* @global string $table the table name
* @global string $goto the URL to go back in case of errors
* @global string $sql_query the SQL query
* @global array $fields_meta the list of fields properties
* @global integer $fields_cnt the total number of fields returned by
* @global string $db the database name
* @global string $table the table name
* @global string $goto the URL to go back in case of errors
* @global string $sql_query the SQL query
* @global array $fields_meta the list of fields properties
* @global integer $fields_cnt the total number of fields returned by
* the SQL query
* @global array $vertical_display informations used with vertical display
* @global array $vertical_display informations used with vertical display
* mode
* @global array $highlight_columns column names to highlight
* @global array $row current row data
* @global array $highlight_columns column names to highlight
* @global array $row current row data
*
* @access private
* @access private
*
* @see PMA_displayTable()
*/
function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
{
global $db, $table, $goto;
global $sql_query, $fields_meta, $fields_cnt;
global $vertical_display, $highlight_columns;
@ -1296,8 +1319,8 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
$edit_url = 'tbl_change.php' . PMA_generate_common_url($_url_params + array('default_action' => 'update'));
$copy_url = 'tbl_change.php' . PMA_generate_common_url($_url_params + array('default_action' => 'insert'));
$edit_str = PMA_getIcon('b_edit.png', __('Edit'), true);
$copy_str = PMA_getIcon('b_insrow.png', __('Copy'), true);
$edit_str = PMA_getIcon('b_edit.png', __('Edit'));
$copy_str = PMA_getIcon('b_insrow.png', __('Copy'));
// Class definitions required for inline editing jQuery scripts
$edit_anchor_class = "edit_row_anchor";
@ -1332,7 +1355,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
$js_conf = 'DELETE FROM ' . PMA_jsFormat($db) . '.' . PMA_jsFormat($table)
. ' WHERE ' . PMA_jsFormat($where_clause, false)
. ($clause_is_unique ? '' : ' LIMIT 1');
$del_str = PMA_getIcon('b_drop.png', __('Delete'), true);
$del_str = PMA_getIcon('b_drop.png', __('Delete'));
} elseif ($is_display['del_lnk'] == 'kp') { // kill process case
$_url_params = array(
@ -1351,7 +1374,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
$del_url = 'sql.php' . PMA_generate_common_url($_url_params);
$del_query = 'KILL ' . $row[0];
$js_conf = 'KILL ' . $row[0];
$del_str = PMA_getIcon('b_drop.png', __('Kill'), true);
$del_str = PMA_getIcon('b_drop.png', __('Kill'));
} // end if (1.2.2)
// 1.3 Displays the links at left if required
@ -2382,7 +2405,8 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
}
} // end of the 'PMA_displayTable()' function
function default_function($buffer) {
function default_function($buffer)
{
$buffer = htmlspecialchars($buffer);
$buffer = str_replace("\011", ' &nbsp;&nbsp;&nbsp;',
str_replace(' ', ' &nbsp;', $buffer));
@ -2410,7 +2434,8 @@ function default_function($buffer) {
* PMA_displayTableNavigation(), PMA_displayTableHeaders(),
* PMA_displayTableBody(), PMA_displayResultsOperations()
*/
function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) {
function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql)
{
global $db, $table, $sql_query, $unlim_num_rows, $fields_meta;
$header_shown = false;
@ -2435,14 +2460,14 @@ function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) {
echo PMA_linkOrButton(
'sql.php' . $url_query,
PMA_getIcon('b_print.png', __('Print view'), false, true),
PMA_getIcon('b_print.png', __('Print view')),
'', true, true, 'print_view') . "\n";
if ($_SESSION['tmp_user_values']['display_text']) {
$_url_params['display_text'] = 'F';
echo PMA_linkOrButton(
'sql.php' . PMA_generate_common_url($_url_params),
PMA_getIcon('b_print.png', __('Print view (with full texts)'), false, true),
PMA_getIcon('b_print.png', __('Print view (with full texts)')),
'', true, true, 'print_view') . "\n";
unset($_url_params['display_text']);
}
@ -2484,13 +2509,13 @@ function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) {
echo PMA_linkOrButton(
'tbl_export.php' . PMA_generate_common_url($_url_params),
PMA_getIcon('b_tblexport.png', __('Export'), false, true),
PMA_getIcon('b_tblexport.png', __('Export')),
'', true, true, '') . "\n";
// show chart
echo PMA_linkOrButton(
'tbl_chart.php' . PMA_generate_common_url($_url_params),
PMA_getIcon('b_chart.png', __('Display chart'), false, true),
PMA_getIcon('b_chart.png', __('Display chart')),
'', true, true, '') . "\n";
// show GIS chart
@ -2505,7 +2530,7 @@ function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) {
if ($geometry_found) {
echo PMA_linkOrButton(
'tbl_gis_visualization.php' . PMA_generate_common_url($_url_params),
PMA_getIcon('b_globe.gif', __('Visualize GIS data'), false, true),
PMA_getIcon('b_globe.gif', __('Visualize GIS data')),
'', true, true, '') . "\n";
}
}
@ -2525,7 +2550,7 @@ function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) {
if (! isset($analyzed_sql[0]['queryflags']['procedure'])) {
echo PMA_linkOrButton(
'view_create.php' . $url_query,
PMA_getIcon('b_views.png', __('Create view'), false, true),
PMA_getIcon('b_views.png', __('Create view')),
'', true, true, '') . "\n";
}
if ($header_shown) {
@ -2537,15 +2562,16 @@ function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) {
* Verifies what to do with non-printable contents (binary or BLOB)
* in Browse mode.
*
* @param string $category BLOB|BINARY|GEOMETRY
* @param string $content the binary content
* @param string $transform_function
* @param string $transform_options
* @param string $default_function
* @param object $meta the meta-information about this field
* @param string $category BLOB|BINARY|GEOMETRY
* @param string $content the binary content
* @param string $transform_function transformation function
* @param string $transform_options transformation parameters
* @param string $default_function default transformation function
* @param object $meta the meta-information about this field
* @return mixed string or float
*/
function PMA_handle_non_printable_contents($category, $content, $transform_function, $transform_options, $default_function, $meta, $url_params = array()) {
function PMA_handle_non_printable_contents($category, $content, $transform_function, $transform_options, $default_function, $meta, $url_params = array())
{
$result = '[' . $category;
if (is_null($content)) {
$result .= ' - NULL';
@ -2582,20 +2608,21 @@ function PMA_handle_non_printable_contents($category, $content, $transform_funct
* Prepares the displayable content of a data cell in Browse mode,
* taking into account foreign key description field and transformations
*
* @param string $class
* @param string $condition_field
* @param string $analyzed_sql
* @param object $meta the meta-information about this field
* @param string $map
* @param string $data
* @param string $transform_function
* @param string $default_function
* @param string $nowrap
* @param string $where_comparison
* @param bool $is_field_truncated
* @param string $class
* @param string $condition_field
* @param string $analyzed_sql
* @param object $meta the meta-information about this field
* @param string $map
* @param string $data
* @param string $transform_function
* @param string $default_function
* @param string $nowrap
* @param string $where_comparison
* @param bool $is_field_truncated
* @return string formatted data
*/
function PMA_prepare_row_data($class, $condition_field, $analyzed_sql, $meta, $map, $data, $transform_function, $default_function, $nowrap, $where_comparison, $transform_options, $is_field_truncated ) {
function PMA_prepare_row_data($class, $condition_field, $analyzed_sql, $meta, $map, $data, $transform_function, $default_function, $nowrap, $where_comparison, $transform_options, $is_field_truncated )
{
$result = ' class="' . PMA_addClass($class, $condition_field, $meta, $nowrap, $is_field_truncated, $transform_function, $default_function) . '">';
@ -2683,17 +2710,18 @@ function PMA_prepare_row_data($class, $condition_field, $analyzed_sql, $meta, $m
/**
* Generates a checkbox for multi-row submits
*
* @param string $del_url
* @param array $is_display
* @param string $row_no
* @param string $where_clause_html
* @param string $del_query
* @param string $id_suffix
* @param string $class
* @param string $del_url
* @param array $is_display
* @param string $row_no
* @param string $where_clause_html
* @param string $del_query
* @param string $id_suffix
* @param string $class
* @return string the generated HTML
*/
function PMA_generateCheckboxForMulti($del_url, $is_display, $row_no, $where_clause_html, $del_query, $id_suffix, $class) {
function PMA_generateCheckboxForMulti($del_url, $is_display, $row_no, $where_clause_html, $del_query, $id_suffix, $class)
{
$ret = '';
if (! empty($del_url) && $is_display['del_lnk'] != 'kp') {
$ret .= '<td ';
@ -2712,14 +2740,15 @@ function PMA_generateCheckboxForMulti($del_url, $is_display, $row_no, $where_cla
/**
* Generates an Edit link
*
* @param string $edit_url
* @param string $class
* @param string $edit_str
* @param string $where_clause
* @param string $where_clause_html
* @param string $edit_url
* @param string $class
* @param string $edit_str
* @param string $where_clause
* @param string $where_clause_html
* @return string the generated HTML
*/
function PMA_generateEditLink($edit_url, $class, $edit_str, $where_clause, $where_clause_html) {
function PMA_generateEditLink($edit_url, $class, $edit_str, $where_clause, $where_clause_html)
{
$ret = '';
if (! empty($edit_url)) {
$ret .= '<td class="' . $class . '" align="center" ' . ' ><span class="nowrap">'
@ -2739,13 +2768,14 @@ function PMA_generateEditLink($edit_url, $class, $edit_str, $where_clause, $wher
/**
* Generates an Copy link
*
* @param string $copy_url
* @param string $copy_str
* @param string $where_clause
* @param string $where_clause_html
* @param string $copy_url
* @param string $copy_str
* @param string $where_clause
* @param string $where_clause_html
* @return string the generated HTML
*/
function PMA_generateCopyLink($copy_url, $copy_str, $where_clause, $where_clause_html, $class) {
function PMA_generateCopyLink($copy_url, $copy_str, $where_clause, $where_clause_html, $class)
{
$ret = '';
if (! empty($copy_url)) {
$ret .= '<td ';
@ -2769,13 +2799,14 @@ function PMA_generateCopyLink($copy_url, $copy_str, $where_clause, $where_clause
/**
* Generates a Delete link
*
* @param string $del_url
* @param string $del_str
* @param string $js_conf
* @param string $class
* @param string $del_url
* @param string $del_str
* @param string $js_conf
* @param string $class
* @return string the generated HTML
*/
function PMA_generateDeleteLink($del_url, $del_str, $js_conf, $class) {
function PMA_generateDeleteLink($del_url, $del_str, $js_conf, $class)
{
$ret = '';
if (! empty($del_url)) {
$ret .= '<td ';
@ -2793,23 +2824,24 @@ function PMA_generateDeleteLink($del_url, $del_str, $js_conf, $class) {
* Generates checkbox and links at some position (left or right)
* (only called for horizontal mode)
*
* @param string $position
* @param string $del_url
* @param array $is_display
* @param string $row_no
* @param string $where_clause
* @param string $where_clause_html
* @param string $del_query
* @param string $id_suffix
* @param string $edit_url
* @param string $copy_url
* @param string $class
* @param string $edit_str
* @param string $del_str
* @param string $js_conf
* @param string $position
* @param string $del_url
* @param array $is_display
* @param string $row_no
* @param string $where_clause
* @param string $where_clause_html
* @param string $del_query
* @param string $id_suffix
* @param string $edit_url
* @param string $copy_url
* @param string $class
* @param string $edit_str
* @param string $del_str
* @param string $js_conf
* @return string the generated HTML
*/
function PMA_generateCheckboxAndLinks($position, $del_url, $is_display, $row_no, $where_clause, $where_clause_html, $del_query, $id_suffix, $edit_url, $copy_url, $class, $edit_str, $copy_str, $del_str, $js_conf) {
function PMA_generateCheckboxAndLinks($position, $del_url, $is_display, $row_no, $where_clause, $where_clause_html, $del_query, $id_suffix, $edit_url, $copy_url, $class, $edit_str, $copy_str, $del_str, $js_conf)
{
$ret = '';
if ($position == 'left') {

View File

@ -248,15 +248,15 @@ if (isset($plugin_list)) {
}
$schema_insert = '<tr class="print-category">';
$schema_insert .= '<th class="print">' . htmlspecialchars(__('Column')) . '</th>';
$schema_insert .= '<td class="print"><b>' . htmlspecialchars(__('Type')) . '</b></td>';
$schema_insert .= '<td class="print"><b>' . htmlspecialchars(__('Null')) . '</b></td>';
$schema_insert .= '<td class="print"><b>' . htmlspecialchars(__('Default')) . '</b></td>';
$schema_insert .= '<th class="print">' . __('Column') . '</th>';
$schema_insert .= '<td class="print"><b>' . __('Type') . '</b></td>';
$schema_insert .= '<td class="print"><b>' . __('Null') . '</b></td>';
$schema_insert .= '<td class="print"><b>' . __('Default') . '</b></td>';
if ($do_relation && $have_rel) {
$schema_insert .= '<td class="print"><b>' . htmlspecialchars(__('Links to')) . '</b></td>';
$schema_insert .= '<td class="print"><b>' . __('Links to') . '</b></td>';
}
if ($do_comments) {
$schema_insert .= '<td class="print"><b>' . htmlspecialchars(__('Comments')) . '</b></td>';
$schema_insert .= '<td class="print"><b>' . __('Comments') . '</b></td>';
$comments = PMA_getComments($db, $table);
}
if ($do_mime && $cfgRelation['mimework']) {
@ -273,40 +273,13 @@ if (isset($plugin_list)) {
foreach ($columns as $column) {
$schema_insert = '<tr class="print-category">';
$type = $column['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 = '&nbsp;';
}
$extracted_fieldspec = PMA_extractFieldSpec($column['Type']);
$type = htmlspecialchars($extracted_fieldspec['print_type']);
if (empty($type)) {
$type = '&nbsp;';
}
$binary = preg_match('/BINARY/i', $column['Type']);
$unsigned = preg_match('/UNSIGNED/i', $column['Type']);
$zerofill = preg_match('/ZEROFILL/i', $column['Type']);
}
$attribute = '&nbsp;';
if ($binary) {
$attribute = 'BINARY';
}
if ($unsigned) {
$attribute = 'UNSIGNED';
}
if ($zerofill) {
$attribute = 'UNSIGNED ZEROFILL';
}
if (! isset($column['Default'])) {
if ($column['Null'] != 'NO') {
$column['Default'] = 'NULL';
@ -325,7 +298,7 @@ if (isset($plugin_list)) {
}
$schema_insert .= '<td class="print">' . $fmt_pre . htmlspecialchars($column['Field']) . $fmt_post . '</td>';
$schema_insert .= '<td class="print">' . htmlspecialchars($type) . '</td>';
$schema_insert .= '<td class="print">' . htmlspecialchars(($column['Null'] == '' || $column['Null'] == 'NO') ? __('No') : __('Yes')) . '</td>';
$schema_insert .= '<td class="print">' . (($column['Null'] == '' || $column['Null'] == 'NO') ? __('No') : __('Yes')) . '</td>';
$schema_insert .= '<td class="print">' . htmlspecialchars(isset($column['Default']) ? $column['Default'] : '') . '</td>';
$field_name = $column['Field'];

View File

@ -148,7 +148,7 @@ if (isset($plugin_list)) {
function PMA_exportDBHeader($db) {
global $crlf;
$head = '% ' . $crlf
. '% ' . __('Database') . ': ' . (isset($GLOBALS['use_backquotes']) ? PMA_backquote($db) : '\'' . $db . '\''). $crlf
. '% ' . __('Database') . ': ' . '\'' . $db . '\'' . $crlf
. '% ' . $crlf;
return PMA_exportOutputHandler($head);
}
@ -391,30 +391,12 @@ if (isset($plugin_list)) {
$fields = PMA_DBI_get_columns($db, $table);
foreach ($fields as $row) {
$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 = '&nbsp;';
}
$binary = preg_match('/BINARY/i', $row['Type']);
$unsigned = preg_match('/UNSIGNED/i', $row['Type']);
$zerofill = preg_match('/ZEROFILL/i', $row['Type']);
$extracted_fieldspec = PMA_extractFieldSpec($row['Type']);
$type = $extracted_fieldspec['print_type'];
if (empty($type)) {
$type = ' ';
}
if (!isset($row['Default'])) {
if ($row['Null'] != 'NO') {
$row['Default'] = 'NULL';

View File

@ -106,7 +106,7 @@ if (isset($plugin_list)) {
* @access public
*/
function PMA_exportDBHeader($db) {
$GLOBALS['odt_buffer'] .= '<text:h text:outline-level="1" text:style-name="Heading_1" text:is-list-header="true">' . htmlspecialchars(__('Database') . ' ' . $db) . '</text:h>';
$GLOBALS['odt_buffer'] .= '<text:h text:outline-level="1" text:style-name="Heading_1" text:is-list-header="true">' . __('Database') . ' ' . htmlspecialchars($db) . '</text:h>';
return true;
}
@ -158,7 +158,7 @@ if (isset($plugin_list)) {
$field_flags[$j] = PMA_DBI_field_flags($result, $j);
}
$GLOBALS['odt_buffer'] .= '<text:h text:outline-level="2" text:style-name="Heading_2" text:is-list-header="true">' . htmlspecialchars(__('Dumping data for table') . ' ' . $table) . '</text:h>';
$GLOBALS['odt_buffer'] .= '<text:h text:outline-level="2" text:style-name="Heading_2" text:is-list-header="true">' . __('Dumping data for table') . ' ' . htmlspecialchars($table) . '</text:h>';
$GLOBALS['odt_buffer'] .= '<table:table table:name="' . htmlspecialchars($table) . '_structure">';
$GLOBALS['odt_buffer'] .= '<table:table-column table:number-columns-repeated="' . $fields_cnt . '"/>';
@ -232,7 +232,7 @@ if (isset($plugin_list)) {
global $cfgRelation;
/* Heading */
$GLOBALS['odt_buffer'] .= '<text:h text:outline-level="2" text:style-name="Heading_2" text:is-list-header="true">' . htmlspecialchars(__('Table structure for table') . ' ' . $table) . '</text:h>';
$GLOBALS['odt_buffer'] .= '<text:h text:outline-level="2" text:style-name="Heading_2" text:is-list-header="true">' . __('Table structure for table') . ' ' . htmlspecialchars($table) . '</text:h>';
/**
* Get the unique keys in the table
@ -285,31 +285,31 @@ if (isset($plugin_list)) {
/* Header */
$GLOBALS['odt_buffer'] .= '<table:table-row>';
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars(__('Column')) . '</text:p>'
. '<text:p>' . __('Column') . '</text:p>'
. '</table:table-cell>';
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars(__('Type')) . '</text:p>'
. '<text:p>' . __('Type') . '</text:p>'
. '</table:table-cell>';
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars(__('Null')) . '</text:p>'
. '<text:p>' . __('Null') . '</text:p>'
. '</table:table-cell>';
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars(__('Default')) . '</text:p>'
. '<text:p>' . __('Default') . '</text:p>'
. '</table:table-cell>';
if ($do_relation && $have_rel) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars(__('Links to')) . '</text:p>'
. '<text:p>' . __('Links to') . '</text:p>'
. '</table:table-cell>';
}
if ($do_comments) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars(__('Comments')) . '</text:p>'
. '<text:p>' . __('Comments') . '</text:p>'
. '</table:table-cell>';
$comments = PMA_getComments($db, $table);
}
if ($do_mime && $cfgRelation['mimework']) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars(__('MIME type')) . '</text:p>'
. '<text:p>' . __('MIME type') . '</text:p>'
. '</table:table-cell>';
$mime_map = PMA_getMIME($db, $table, true);
}
@ -317,36 +317,18 @@ if (isset($plugin_list)) {
$columns = PMA_DBI_get_columns($db, $table);
foreach ($columns as $column) {
$field_name = $column['Field'];
$GLOBALS['odt_buffer'] .= '<table:table-row>';
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars($field_name) . '</text:p>'
. '</table:table-cell>';
// reformat mysql query output
// set or enum types: slashes single quotes inside options
$type = $column['Type'];
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 = '&nbsp;';
}
$binary = preg_match('/BINARY/i', $column['Type']);
$unsigned = preg_match('/UNSIGNED/i', $column['Type']);
$zerofill = preg_match('/ZEROFILL/i', $column['Type']);
$extracted_fieldspec = PMA_extractFieldSpec($column['Type']);
$type = htmlspecialchars($extracted_fieldspec['print_type']);
if (empty($type)) {
$type = '&nbsp;';
}
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars($type) . '</text:p>'
. '</table:table-cell>';
@ -360,7 +342,7 @@ if (isset($plugin_list)) {
$column['Default'] = $column['Default'];
}
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars(($column['Null'] == '' || $column['Null'] == 'NO') ? __('No') : __('Yes')) . '</text:p>'
. '<text:p>' . (($column['Null'] == '' || $column['Null'] == 'NO') ? __('No') : __('Yes')) . '</text:p>'
. '</table:table-cell>';
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars($column['Default']) . '</text:p>'

View File

@ -1068,7 +1068,7 @@ if (isset($plugin_list)) {
// a possible error: the table has crashed
$tmp_error = PMA_DBI_getError();
if ($tmp_error) {
return PMA_exportOutputHandler(PMA_exportComment(__('in use') . ' (' . $tmp_error . ')'));
return PMA_exportOutputHandler(PMA_exportComment(__('Error reading data:') . ' (' . $tmp_error . ')'));
}
if ($result != false) {

View File

@ -227,15 +227,15 @@ if (isset($plugin_list)) {
}
$text_output = "|------\n";
$text_output .= '|' . htmlspecialchars(__('Column'));
$text_output .= '|' . htmlspecialchars(__('Type'));
$text_output .= '|' . htmlspecialchars(__('Null'));
$text_output .= '|' . htmlspecialchars(__('Default'));
$text_output .= '|' . __('Column');
$text_output .= '|' . __('Type');
$text_output .= '|' . __('Null');
$text_output .= '|' . __('Default');
if ($do_relation && $have_rel) {
$text_output .= '|' . htmlspecialchars(__('Links to'));
$text_output .= '|' . __('Links to');
}
if ($do_comments) {
$text_output .= '|' . htmlspecialchars(__('Comments'));
$text_output .= '|' . __('Comments');
$comments = PMA_getComments($db, $table);
}
if ($do_mime && $cfgRelation['mimework']) {
@ -252,40 +252,13 @@ if (isset($plugin_list)) {
foreach ($columns as $column) {
$text_output = '';
$type = $column['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 = '&nbsp;';
}
$extracted_fieldspec = PMA_extractFieldSpec($column['Type']);
$type = $extracted_fieldspec['print_type'];
if (empty($type)) {
$type = '&nbsp;';
}
$binary = preg_match('/BINARY/i', $column['Type']);
$unsigned = preg_match('/UNSIGNED/i', $column['Type']);
$zerofill = preg_match('/ZEROFILL/i', $column['Type']);
}
$attribute = '&nbsp;';
if ($binary) {
$attribute = 'BINARY';
}
if ($unsigned) {
$attribute = 'UNSIGNED';
}
if ($zerofill) {
$attribute = 'UNSIGNED ZEROFILL';
}
if (! isset($column['Default'])) {
if ($column['Null'] != 'NO') {
$column['Default'] = 'NULL';
@ -304,7 +277,7 @@ if (isset($plugin_list)) {
}
$text_output .= '|' . $fmt_pre . htmlspecialchars($column['Field']) . $fmt_post;
$text_output .= '|' . htmlspecialchars($type);
$text_output .= '|' . htmlspecialchars(($column['Null'] == '' || $column['Null'] == 'NO') ? __('No') : __('Yes'));
$text_output .= '|' . (($column['Null'] == '' || $column['Null'] == 'NO') ? __('No') : __('Yes'));
$text_output .= '|' . htmlspecialchars(isset($column['Default']) ? $column['Default'] : '');
$field_name = $column['Field'];

View File

@ -11,6 +11,8 @@ if (! defined('PHPMYADMIN')) {
}
if (strlen($GLOBALS['db'])) { /* Can't do server export */
return;
}
if (isset($plugin_list)) {
$plugin_list['xml'] = array(
@ -26,26 +28,54 @@ if (isset($plugin_list)) {
);
/* Export structure */
$plugin_list['xml']['options'][] =
array('type' => 'begin_group', 'name' => 'structure', 'text' => __('Object creation options (all are recommended)'));
$plugin_list['xml']['options'][] =
array('type' => 'bool', 'name' => 'export_functions', 'text' => __('Functions'));
$plugin_list['xml']['options'][] =
array('type' => 'bool', 'name' => 'export_procedures', 'text' => __('Procedures'));
$plugin_list['xml']['options'][] =
array('type' => 'bool', 'name' => 'export_tables', 'text' => __('Tables'));
$plugin_list['xml']['options'][] =
array('type' => 'bool', 'name' => 'export_triggers', 'text' => __('Triggers'));
$plugin_list['xml']['options'][] =
array('type' => 'bool', 'name' => 'export_views', 'text' => __('Views'));
$plugin_list['xml']['options'][] = array('type' => 'end_group');
$plugin_list['xml']['options'][] = array(
'type' => 'begin_group',
'name' => 'structure',
'text' => __('Object creation options (all are recommended)')
);
$plugin_list['xml']['options'][] = array(
'type' => 'bool',
'name' => 'export_functions',
'text' => __('Functions')
);
$plugin_list['xml']['options'][] = array(
'type' => 'bool',
'name' => 'export_procedures',
'text' => __('Procedures')
);
$plugin_list['xml']['options'][] = array(
'type' => 'bool',
'name' => 'export_tables',
'text' => __('Tables')
);
$plugin_list['xml']['options'][] = array(
'type' => 'bool',
'name' => 'export_triggers',
'text' => __('Triggers')
);
$plugin_list['xml']['options'][] = array(
'type' => 'bool',
'name' => 'export_views',
'text' => __('Views')
);
$plugin_list['xml']['options'][] = array(
'type' => 'end_group'
);
/* Data */
$plugin_list['xml']['options'][] =
array('type' => 'begin_group', 'name' => 'data', 'text' => __('Data dump options'));
$plugin_list['xml']['options'][] =
array('type' => 'bool', 'name' => 'export_contents', 'text' => __('Export contents'));
$plugin_list['xml']['options'][] = array('type' => 'end_group');
$plugin_list['xml']['options'][] = array(
'type' => 'begin_group',
'name' => 'data',
'text' => __('Data dump options')
);
$plugin_list['xml']['options'][] = array(
'type' => 'bool',
'name' => 'export_contents',
'text' => __('Export contents')
);
$plugin_list['xml']['options'][] = array(
'type' => 'end_group'
);
} else {
/**
@ -243,7 +273,7 @@ if (isset($plugin_list)) {
if (isset($GLOBALS['xml_export_contents']) && $GLOBALS['xml_export_contents']) {
$head = ' <!--' . $crlf
. ' - ' . __('Database') . ': ' . (isset($GLOBALS['use_backquotes']) ? PMA_backquote($db) : '\'' . $db . '\''). $crlf
. ' - ' . __('Database') . ': ' . '\'' . $db . '\'' . $crlf
. ' -->' . $crlf
. ' <database name="' . htmlspecialchars($db) . '">' . $crlf;
@ -337,6 +367,5 @@ if (isset($plugin_list)) {
return true;
} // end of the 'PMA_getTableXML()' function
}
}
?>

View File

@ -133,16 +133,7 @@ class PMA_GIS_Visualization
ob_clean();
header('Content-type: ' . $type);
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Disposition: Attachment;filename=' . $file_name);
if (PMA_USR_BROWSER_AGENT == 'IE') {
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
} else {
header('Pragma: no-cache');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
}
PMA_download_header($file_name, $type);
}
/**

View File

@ -18,7 +18,8 @@ require_once './libraries/RecentTable.class.php';
* @param string $db Database name where the table is located.
* @param string $table The table name
*/
function PMA_addRecentTable($db, $table) {
function PMA_addRecentTable($db, $table)
{
$tmp_result = PMA_RecentTable::getInstance()->add($db, $table);
if ($tmp_result === true) {
echo '<span class="hide" id="update_recent_tables"></span>';

View File

@ -24,10 +24,7 @@ if (!$GLOBALS['cfg']['AllowThirdPartyFraming']) {
header('X-Frame-Options: SAMEORIGIN');
header('X-Content-Security-Policy: allow \'self\'; options inline-script eval-script; frame-ancestors \'self\'; img-src \'self\' data:; script-src \'self\' www.phpmyadmin.net');
}
header('Expires: ' . $GLOBALS['now']); // rfc2616 - Section 14.21
header('Last-Modified: ' . $GLOBALS['now']);
header('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
header('Pragma: no-cache'); // HTTP/1.0
PMA_no_cache_header();
if (!defined('IS_TRANSFORMATION_WRAPPER')) {
// Define the charset to be used
header('Content-Type: text/html; charset=utf-8');

View File

@ -49,7 +49,8 @@ $gnu_iconv_to_aix_iconv_codepage_map = array (
* @access public
*
*/
function PMA_aix_iconv_wrapper($in_charset, $out_charset, $str) {
function PMA_aix_iconv_wrapper($in_charset, $out_charset, $str)
{
global $gnu_iconv_to_aix_iconv_codepage_map;

View File

@ -381,7 +381,8 @@ function PMA_getColumnAlphaName($num)
* @param string $name (i.e. "A", or "BC", etc.)
* @return int The column number
*/
function PMA_getColumnNumberFromName($name) {
function PMA_getColumnNumberFromName($name)
{
if (!empty($name)) {
$name = strtoupper($name);
$num_chars = strlen($name);
@ -442,7 +443,8 @@ define("FORMATTEDSQL", 2);
* @param string $last_cumulative_size
* @return int Precision of the given decimal size notation
*/
function PMA_getM($last_cumulative_size) {
function PMA_getM($last_cumulative_size)
{
return (int)substr($last_cumulative_size, 0, strpos($last_cumulative_size, ","));
}
@ -454,7 +456,8 @@ function PMA_getM($last_cumulative_size) {
* @param string $last_cumulative_size
* @return int Scale of the given decimal size notation
*/
function PMA_getD($last_cumulative_size) {
function PMA_getD($last_cumulative_size)
{
return (int)substr($last_cumulative_size, (strpos($last_cumulative_size, ",") + 1), (strlen($last_cumulative_size) - strpos($last_cumulative_size, ",")));
}
@ -466,7 +469,8 @@ function PMA_getD($last_cumulative_size) {
* @param string &$cell
* @return array Contains the precision, scale, and full size representation of the given decimal cell
*/
function PMA_getDecimalSize(&$cell) {
function PMA_getDecimalSize(&$cell)
{
$curr_size = strlen((string)$cell);
$decPos = strpos($cell, ".");
$decPrecision = ($curr_size - 1) - $decPos;
@ -490,7 +494,8 @@ function PMA_getDecimalSize(&$cell) {
* @param string &$cell The current cell
* @return string Size of the given cell in the type-appropriate format
*/
function PMA_detectSize($last_cumulative_size, $last_cumulative_type, $curr_type, &$cell) {
function PMA_detectSize($last_cumulative_size, $last_cumulative_type, $curr_type, &$cell)
{
$curr_size = strlen((string)$cell);
/**
@ -699,7 +704,8 @@ function PMA_detectSize($last_cumulative_size, $last_cumulative_type, $curr_type
* @param string &$cell String representation of the cell for which a best-fit type is to be determined
* @return int The MySQL type representation (VARCHAR or INT or BIGINT or DECIMAL or NONE)
*/
function PMA_detectType($last_cumulative_type, &$cell) {
function PMA_detectType($last_cumulative_type, &$cell)
{
/**
* If numeric, determine if decimal, int or bigint
* Else, we call it varchar for simplicity
@ -738,7 +744,8 @@ function PMA_detectType($last_cumulative_type, &$cell) {
* @param &$table array(string $table_name, array $col_names, array $rows)
* @return array array(array $types, array $sizes)
*/
function PMA_analyzeTable(&$table) {
function PMA_analyzeTable(&$table)
{
/* Get number of rows in table */
$numRows = count($table[ROWS]);
/* Get number of columns */
@ -835,7 +842,8 @@ $import_notice = null;
* @param array $options Associative array of options
* @return void
*/
function PMA_buildSQL($db_name, &$tables, &$analyses = null, &$additional_sql = null, $options = null) {
function PMA_buildSQL($db_name, &$tables, &$analyses = null, &$additional_sql = null, $options = null)
{
/* Take care of the options */
if (isset($options['db_collation'])&& ! is_null($options['db_collation'])) {
$collation = $options['db_collation'];
@ -1080,14 +1088,14 @@ function PMA_buildSQL($db_name, &$tables, &$analyses = null, &$additional_sql =
$message = '<br /><br />';
$message .= '<strong>' . __('The following structures have either been created or altered. Here you can:') . '</strong><br />';
$message .= '<ul><li>' . __("View a structure's contents by clicking on its name") . '</li>';
$message .= '<li>' . htmlspecialchars(__('Change any of its settings by clicking the corresponding "Options" link')) . '</li>';
$message .= '<li>' . htmlspecialchars(__('Edit structure by following the "Structure" link')) . '</li>';
$message .= '<li>' . __('Change any of its settings by clicking the corresponding "Options" link') . '</li>';
$message .= '<li>' . __('Edit structure by following the "Structure" link') . '</li>';
$message .= sprintf('<br /><li><a href="%s" title="%s">%s</a> (<a href="%s" title="%s">' . __('Options') . '</a>)</li>',
$db_url,
__('Go to database') . ': ' . htmlspecialchars(PMA_backquote($db_name)),
htmlspecialchars($db_name),
$db_ops_url,
__('Edit') . ' ' . htmlspecialchars(PMA_backquote($db_name)) . ' ' . __('settings'));
sprintf(__('Edit settings for %s'), htmlspecialchars(PMA_backquote($db_name))));
$message .= '<ul>';
@ -1109,9 +1117,9 @@ function PMA_buildSQL($db_name, &$tables, &$analyses = null, &$additional_sql =
__('Go to table') . ': ' . htmlspecialchars(PMA_backquote($tables[$i][TBL_NAME])),
htmlspecialchars($tables[$i][TBL_NAME]),
$tbl_struct_url,
htmlspecialchars(PMA_backquote($tables[$i][TBL_NAME])) . ' ' . __('structure'),
sprintf(__('Structure of %s'), htmlspecialchars(PMA_backquote($tables[$i][TBL_NAME]))),
$tbl_ops_url,
__('Edit') . ' ' . htmlspecialchars(PMA_backquote($tables[$i][TBL_NAME])) . ' ' . __('settings'));
sprintf(__('Edit settings for %s'), htmlspecialchars(PMA_backquote($db_name))));
} else {
$message .= sprintf('<li><a href="%s" title="%s">%s</a></li>',
$tbl_url,

View File

@ -16,7 +16,8 @@ $ID_KEY = 'APC_UPLOAD_PROGRESS';
*
* This is implementation for APC extension.
*/
function PMA_getUploadStatus($id) {
function PMA_getUploadStatus($id)
{
global $SESSION_KEY;
global $ID_KEY;

View File

@ -16,7 +16,8 @@ $ID_KEY = 'noplugin';
*
* This is implementation when no webserver support exists, so it returns just zeroes.
*/
function PMA_getUploadStatus($id) {
function PMA_getUploadStatus($id)
{
global $SESSION_KEY;
global $ID_KEY;

View File

@ -15,7 +15,8 @@ $ID_KEY = "UPLOAD_IDENTIFIER";
*
* This is implementation for uploadprogress extension.
*/
function PMA_getUploadStatus($id) {
function PMA_getUploadStatus($id)
{
global $SESSION_KEY;
global $ID_KEY;

View File

@ -64,7 +64,8 @@ function PMA_escapeJsString($string)
* @param string $key Name of value to set
* @param mixed $value Value to set, can be either string or array of strings
*/
function PMA_printJsValue($key, $value) {
function PMA_printJsValue($key, $value)
{
echo $key . ' = ';
if (is_array($value)) {
echo '[';

View File

@ -25,7 +25,8 @@ if (! defined('PHPMYADMIN')) {
*
* @return boolean always true
*/
function PMA_internal_enc_check() {
function PMA_internal_enc_check()
{
global $internal_enc, $enc_list;
$internal_enc = mb_internal_encoding();
@ -47,7 +48,8 @@ function PMA_internal_enc_check() {
*
* @return boolean always true
*/
function PMA_change_enc_order() {
function PMA_change_enc_order()
{
global $enc_list;
$p = explode(',', $enc_list);
@ -73,7 +75,8 @@ function PMA_change_enc_order() {
*
* @return string the converted string
*/
function PMA_kanji_str_conv($str, $enc, $kana) {
function PMA_kanji_str_conv($str, $enc, $kana)
{
global $enc_list;
if ($enc == '' && $kana == '') {
@ -104,7 +107,8 @@ function PMA_kanji_str_conv($str, $enc, $kana) {
*
* @return string the name of the converted file
*/
function PMA_kanji_file_conv($file, $enc, $kana) {
function PMA_kanji_file_conv($file, $enc, $kana)
{
if ($enc == '' && $kana == '') {
return $file;
}
@ -135,7 +139,8 @@ function PMA_kanji_file_conv($file, $enc, $kana) {
*
* @return string xhtml code for the radio controls
*/
function PMA_set_enc_form($spaces) {
function PMA_set_enc_form($spaces)
{
return "\n"
/* l10n: This is currently used only in Japanese locales */
. $spaces . '<ul>' . "\n" . '<li>'

View File

@ -11,7 +11,8 @@
/**
* Logs user information to webserver logs.
*/
function PMA_log_user($user, $status = 'ok') {
function PMA_log_user($user, $status = 'ok')
{
if (function_exists('apache_note')) {
apache_note('userID', $user);
apache_note('userStatus', $status);

View File

@ -10,7 +10,8 @@
/**
* Tries to detect MIME type of content.
*/
function PMA_detectMIME(&$test) {
function PMA_detectMIME(&$test)
{
$len = strlen($test);
if ($len >= 2 && $test[0] == chr(0xff) && $test[1] == chr(0xd8)) {
return 'image/jpeg';

View File

@ -145,7 +145,8 @@ function PMA_generateCharsetDropdownBox($type = PMA_CSDROPDOWN_COLLATION,
return $return_str;
}
function PMA_generateCharsetQueryPart($collation) {
function PMA_generateCharsetQueryPart($collation)
{
list($charset) = explode('_', $collation);
return ' CHARACTER SET ' . $charset . ($charset == $collation ? '' : ' COLLATE ' . $collation);
}
@ -156,7 +157,8 @@ function PMA_generateCharsetQueryPart($collation) {
* @param string $db name of db
* @return string collation of $db
*/
function PMA_getDbCollation($db) {
function PMA_getDbCollation($db)
{
if ($db == 'information_schema') {
// We don't have to check the collation of the virtual
// information_schema database: We know it!
@ -181,7 +183,8 @@ function PMA_getDbCollation($db) {
*
* @return string $server_collation
*/
function PMA_getServerCollation() {
function PMA_getServerCollation()
{
return PMA_DBI_fetch_value(
'SHOW VARIABLES LIKE \'collation_server\'', 0, 1);
}
@ -193,7 +196,8 @@ function PMA_getServerCollation() {
* @param string $collation MySQL collation string
* @return string collation description
*/
function PMA_getCollationDescr($collation) {
function PMA_getCollationDescr($collation)
{
if ($collation == 'binary') {
return __('Binary');
}

View File

@ -30,7 +30,8 @@ $GLOBALS['OpenDocumentNS'] = 'xmlns:office="urn:oasis:names:tc:opendocument:xmln
*
* @access public
*/
function PMA_createOpenDocument($mime, $data) {
function PMA_createOpenDocument($mime, $data)
{
$zipfile = new zipfile();
$zipfile -> addFile($mime, 'mimetype');
$zipfile -> addFile($data, 'content.xml');

View File

@ -277,7 +277,7 @@ function PMA__getRelationsParam()
$cfgRelation['displaywork'] = true;
}
}
if (isset($cfgRelation['table_coords']) && isset($cfgRelation['pdf_pages'])) {
$cfgRelation['pdfwork'] = true;
}
@ -513,7 +513,7 @@ function PMA_getComments($db, $table = '')
if ($table != '') {
// MySQL native column comments
$fields = PMA_DBI_get_columns($db, $table);
$fields = PMA_DBI_get_columns($db, $table, true);
if ($fields) {
foreach ($fields as $field) {
if (! empty($field['Comment'])) {
@ -1071,7 +1071,8 @@ function PMA_REL_renameField($db, $table, $field, $new_name)
* @param string $query_default_option
* @return string $pdf_page_number
*/
function PMA_REL_create_page($newpage, $cfgRelation, $db, $query_default_option) {
function PMA_REL_create_page($newpage, $cfgRelation, $db, $query_default_option)
{
if (! isset($newpage) || $newpage == '') {
$newpage = __('no description');
}

View File

@ -140,7 +140,8 @@ foreach ($replication_types as $type) {
* @param $what what to extract (db|table)
* @return $string the extracted part
*/
function PMA_extract_db_or_table($string, $what = 'db') {
function PMA_extract_db_or_table($string, $what = 'db')
{
$list = explode(".", $string);
if ('db' == $what) {
return $list[0];
@ -149,13 +150,14 @@ function PMA_extract_db_or_table($string, $what = 'db') {
}
}
/**
* @param String $action - possible values: START or STOP
* @param String $control - default: null, possible values: SQL_THREAD or IO_THREAD or null. If it is set to null, it controls both SQL_THREAD and IO_THREAD
* @param mixed $link - mysql link
* @param string $action possible values: START or STOP
* @param string $control default: null, possible values: SQL_THREAD or IO_THREAD or null. If it is set to null, it controls both SQL_THREAD and IO_THREAD
* @param mixed $link mysql link
*
* @return mixed output of PMA_DBI_try_query
*/
function PMA_replication_slave_control($action, $control = null, $link = null) {
function PMA_replication_slave_control($action, $control = null, $link = null)
{
$action = strtoupper($action);
$control = strtoupper($control);
@ -169,18 +171,19 @@ function PMA_replication_slave_control($action, $control = null, $link = null) {
return PMA_DBI_try_query($action . " SLAVE " . $control . ";", $link);
}
/**
* @param String $user - replication user on master
* @param String $password - password for the user
* @param String $host - master's hostname or IP
* @param int $port - port, where mysql is running
* @param array $pos - position of mysql replication, array should contain fields File and Position
* @param boolean $stop - shall we stop slave?
* @param boolean $start - shall we start slave?
* @param mixed $link - mysql link
* @param string $user replication user on master
* @param string $password password for the user
* @param string $host master's hostname or IP
* @param int $port port, where mysql is running
* @param array $pos position of mysql replication, array should contain fields File and Position
* @param bool $stop shall we stop slave?
* @param bool $start shall we start slave?
* @param mixed $link mysql link
*
* @return output of CHANGE MASTER mysql command
*/
function PMA_replication_slave_change_master($user, $password, $host, $port, $pos, $stop = true, $start = true, $link = null) {
function PMA_replication_slave_change_master($user, $password, $host, $port, $pos, $stop = true, $start = true, $link = null)
{
if ($stop) {
PMA_replication_slave_control("STOP", null, $link);
}
@ -203,15 +206,16 @@ function PMA_replication_slave_change_master($user, $password, $host, $port, $po
/**
* This function provides connection to remote mysql server
*
* @param String $user - mysql username
* @param String $password - password for the user
* @param String $host - mysql server's hostname or IP
* @param int $port - mysql remote port
* @param String $socket - path to unix socket
* @param string $user mysql username
* @param string $password password for the user
* @param string $host mysql server's hostname or IP
* @param int $port mysql remote port
* @param string $socket path to unix socket
*
* @return mixed $link mysql link on success
*/
function PMA_replication_connect_to_master($user, $password, $host = null, $port = null, $socket = null) {
function PMA_replication_connect_to_master($user, $password, $host = null, $port = null, $socket = null)
{
$server = array();
$server["host"] = $host;
$server["port"] = $port;
@ -222,11 +226,12 @@ function PMA_replication_connect_to_master($user, $password, $host = null, $port
return PMA_DBI_connect($user, $password, false, $server, true);
}
/**
* @param $link - mysql link
* @param mixed $link mysql link
*
* @return array - containing File and Position in MySQL replication on master server, useful for PMA_replication_slave_change_master
*/
function PMA_replication_slave_bin_log_master($link = null) {
function PMA_replication_slave_bin_log_master($link = null)
{
$data = PMA_DBI_fetch_result('SHOW MASTER STATUS', null, null, $link);
$output = array();
@ -240,12 +245,13 @@ function PMA_replication_slave_bin_log_master($link = null) {
/**
* Get list of replicated databases on master server
*
* @param mixed mysql link
* @param mixed $link mysql link
*
* @return array array of replicated databases
*/
function PMA_replication_master_replicated_dbs($link = null) {
function PMA_replication_master_replicated_dbs($link = null)
{
$data = PMA_DBI_fetch_result('SHOW MASTER STATUS', null, null, $link); // let's find out, which databases are replicated
$do_db = array();
@ -279,15 +285,17 @@ function PMA_replication_master_replicated_dbs($link = null) {
}
/**
* This function provides synchronization of structure and data between two mysql servers.
* TODO: improve code sharing between the function and synchronization
*
* @param String $db - name of database, which should be synchronized
* @param mixed $src_link - link of source server, note: if the server is current PMA server, use null
* @param mixed $trg_link - link of target server, note: if the server is current PMA server, use null
* @param boolean $data - if true, then data will be copied as well
* @todo improve code sharing between the function and synchronization
*
* @param string $db name of database, which should be synchronized
* @param mixed $src_link link of source server, note: if the server is current PMA server, use null
* @param mixed $trg_link link of target server, note: if the server is current PMA server, use null
* @param bool $data if true, then data will be copied as well
*/
function PMA_replication_synchronize_db($db, $src_link, $trg_link, $data = true) {
function PMA_replication_synchronize_db($db, $src_link, $trg_link, $data = true)
{
$src_db = $trg_db = $db;
$src_connection = PMA_DBI_select_db($src_db, $src_link);
@ -379,7 +387,7 @@ function PMA_replication_synchronize_db($db, $src_link, $trg_link, $data = true)
/**
* Generating Create Table query for all the non-matching tables present in Source but not in Target and populating tables.
*/
for($q = 0; $q < sizeof($source_tables_uncommon); $q++) {
for ($q = 0; $q < sizeof($source_tables_uncommon); $q++) {
if (isset($uncommon_tables[$q])) {
PMA_createTargetTables($src_db, $trg_db, $src_link, $trg_link, $source_tables_uncommon, $q, $uncommon_tables_fields, false);
}

View File

@ -43,7 +43,8 @@ function PMA_replication_db_multibox()
* @param String $submitname - submit button name
*/
function PMA_replication_gui_changemaster($submitname) {
function PMA_replication_gui_changemaster($submitname)
{
list($username_length, $hostname_length) = PMA_replication_get_username_hostname_length();
@ -80,11 +81,12 @@ function PMA_replication_gui_changemaster($submitname) {
/**
* This function prints out table with replication status.
*
* @param String type - either master or slave
* @param boolean $hidden - if true, then default style is set to hidden, default value false
* @param boolen $title - if true, then title is displayed, default true
* @param string $type either master or slave
* @param boolean $hidden if true, then default style is set to hidden, default value false
* @param boolen $title if true, then title is displayed, default true
*/
function PMA_replication_print_status_table($type, $hidden = false, $title = true) {
function PMA_replication_print_status_table($type, $hidden = false, $title = true)
{
global ${"{$type}_variables"};
global ${"{$type}_variables_alerts"};
global ${"{$type}_variables_oks"};
@ -162,7 +164,8 @@ function PMA_replication_print_status_table($type, $hidden = false, $title = tru
*
* @param boolean $hidden - if true, then default style is set to hidden, default value false
*/
function PMA_replication_print_slaves_table($hidden = false) {
function PMA_replication_print_slaves_table($hidden = false)
{
// Fetch data
$data = PMA_DBI_fetch_result('SHOW SLAVE HOSTS', null, null);
@ -202,7 +205,8 @@ function PMA_replication_print_slaves_table($hidden = false) {
* @return array username length, hostname length
*/
function PMA_replication_get_username_hostname_length() {
function PMA_replication_get_username_hostname_length()
{
$fields_info = PMA_DBI_get_columns('mysql', 'user');
$username_length = 16;
$hostname_length = 41;
@ -227,7 +231,8 @@ function PMA_replication_get_username_hostname_length() {
/**
* Print code to add a replication slave user to the master
*/
function PMA_replication_gui_master_addslaveuser() {
function PMA_replication_gui_master_addslaveuser()
{
list($username_length, $hostname_length) = PMA_replication_get_username_hostname_length();

View File

@ -170,9 +170,8 @@ class PMA_DIA extends XMLWriter
if(ob_get_clean()){
ob_end_clean();
}
header('Content-type: application/x-dia-diagram');
header('Content-Disposition: attachment; filename="'.$fileName.'.dia"');
$output = $this->flush();
PMA_download_header($fileName . '.dia', 'application/x-dia-diagram', strlen($output));
print $output;
}
}

View File

@ -333,9 +333,8 @@ class PMA_EPS
// if(ob_get_clean()){
//ob_end_clean();
//}
header('Content-type: image/x-eps');
header('Content-Disposition: attachment; filename="'.$fileName.'.eps"');
$output = $this->stringCommands;
PMA_download_header($fileName . '.eps', 'image/x-eps', strlen($output));
print $output;
}
}

View File

@ -71,12 +71,17 @@ class PMA_PDF extends TCPDF
parent::_putpages();
}
// added because tcpdf for PHP 5 has a protected $buffer
/**
* Getter for protected buffer.
*/
public function getBuffer()
{
return $this->buffer;
}
/**
* Getter for protected state.
*/
public function getState()
{
return $this->state;
@ -230,9 +235,11 @@ class PMA_PDF extends TCPDF
}
}
/**
* This function must be named "Footer" to work with the TCPDF library
*/
function Footer()
{
// This function must be named "Footer" to work with the TCPDF library
global $with_doc;
if ($with_doc) {
$this->SetY(-15);
@ -243,9 +250,11 @@ class PMA_PDF extends TCPDF
}
}
/**
* Add a bookmark
*/
function Bookmark($txt, $level = 0, $y = 0, $page = '')
{
// Add a bookmark
$this->Outlines[0][] = $level;
$this->Outlines[1][] = $txt;
$this->Outlines[2][] = $this->page;
@ -379,9 +388,11 @@ class PMA_PDF extends TCPDF
$this->Ln($h);
}
/**
* Compute number of lines used by a multicell of width w
*/
function NbLines($w, $txt)
{
// compute number of lines used by a multicell of width w
$cw = &$this->CurrentFont['cw'];
if ($w == 0) {
$w = $this->w - $this->rMargin - $this->x;
@ -1068,9 +1079,7 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
}
// instead of $pdf->Output():
$pdfData = $pdf->getPDFData();
header('Content-Type: application/pdf');
header('Content-Length: '.strlen($pdfData).'');
header('Content-disposition: attachment; filename="'.$filename.'"');
PMA_download_header($filename, 'application/pdf', strlen($pdfData));
echo $pdfData;
}
@ -1178,8 +1187,7 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
/**
* 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);
$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
@ -1261,41 +1269,10 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
}
$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 = '&nbsp;';
}
$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';
}
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';
@ -1327,9 +1304,8 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
unset($links[6]);
}
$pdf->Row($pdf_row, $links);
} // end while
} // end foreach
$pdf->SetFont($this->_ff, '', 14);
PMA_DBI_free_result($result);
} //end each
}
}

View File

@ -168,9 +168,8 @@ class PMA_SVG extends XMLWriter
function showOutput($fileName)
{
//ob_get_clean();
header('Content-type: image/svg+xml');
header('Content-Disposition: attachment; filename="'.$fileName.'.svg"');
$output = $this->flush();
PMA_download_header($fileName . '.svg', 'image/svg+xml', strlen($output));
print $output;
}

View File

@ -155,9 +155,8 @@ class PMA_VISIO extends XMLWriter
//if(ob_get_clean()){
//ob_end_clean();
//}
header('Content-type: application/visio');
header('Content-Disposition: attachment; filename="'.$fileName.'.vdx"');
$output = $this->flush();
PMA_download_header($fileName . '.vdx', 'application/visio', strlen($output));
print $output;
}
}

View File

@ -12,7 +12,8 @@ if (! defined('PHPMYADMIN')) {
/**
* Returns language name
*/
function PMA_langName($tmplang) {
function PMA_langName($tmplang)
{
$lang_name = ucfirst(substr(strrchr($tmplang[0], '|'), 1));
// Include native name if non empty
@ -182,7 +183,8 @@ function PMA_langDetect($str, $envType)
* example.
*
*/
function PMA_langDetails($lang) {
function PMA_langDetails($lang)
{
switch ($lang) {
case 'af':
return array('af|afrikaans', 'af', '');

View File

@ -19,7 +19,6 @@
* @param array &$uncommon_source_tables empty array passed by reference to save
* names of tables present in source database
* but absent from target database
* @return nothing
*/
function PMA_getMatchingTables($trg_tables, $src_tables, &$matching_tables, &$uncommon_source_tables)
{
@ -46,7 +45,6 @@ function PMA_getMatchingTables($trg_tables, $src_tables, &$matching_tables, &$un
* @param array &$uncommon_target_tables empty array passed by reference to save
* names of tables presnet in target database
* but absent from source database
* @return nothing
*/
function PMA_getNonMatchingTargetTables($trg_tables, $matching_tables, &$uncommon_target_tables)
{
@ -85,9 +83,8 @@ function PMA_getNonMatchingTargetTables($trg_tables, $matching_tables, &$uncommo
* @param array &$delete_array Unused
* @param array &$fields_num A two dimensional array passed by reference to
* contain number of fields for each matching table
* @param array $matching_table_index Index of a table from $matching_table array
* @param int $matching_table_index Index of a table from $matching_table array
* @param array &$matching_tables_keys A two dimensional array passed by reference to contain names of keys for each matching table
* @return nothing
*/
function PMA_dataDiffInTables($src_db, $trg_db, $src_link, $trg_link, &$matching_table, &$matching_tables_fields,
&$update_array, &$insert_array, &$delete_array, &$fields_num, $matching_table_index, &$matching_tables_keys)
@ -128,9 +125,6 @@ function PMA_dataDiffInTables($src_db, $trg_db, $src_link, $trg_link, &$matching
}
$update_row = 0;
$insert_row = 0;
$update_field = 0;
$insert_field = 0;
$starting_index = 0;
for ($j = 0; $j < $source_size; $j++) {
$starting_index = 0;
@ -305,17 +299,14 @@ function PMA_dataDiffInTables($src_db, $trg_db, $src_link, $trg_link, &$matching
* @param db_link $trg_link connection established with target server
* @param string $src_db name of source database
* @param db_link $src_link connection established with source server
* @return nothing
*/
function PMA_findDeleteRowsFromTargetTables(&$delete_array, $matching_table, $matching_table_index, $trg_keys, $src_keys, $trg_db, $trg_link, $src_db, $src_link)
{
if (isset($trg_keys[$matching_table_index])) {
$target_key_values = PMA_get_column_values($trg_db, $matching_table[$matching_table_index], $trg_keys[$matching_table_index], $trg_link);
$target_row_size = sizeof($target_key_values);
}
if (isset($src_keys[$matching_table_index])) {
$source_key_values = PMA_get_column_values($src_db, $matching_table[$matching_table_index], $src_keys[$matching_table_index], $src_link);
$source_size = sizeof($source_key_values);
}
$all_keys_match = 1;
for ($a = 0; $a < sizeof($trg_keys[$matching_table_index]); $a++) {
@ -372,12 +363,11 @@ function PMA_findDeleteRowsFromTargetTables(&$delete_array, $matching_table, $ma
/**
* PMA_dataDiffInUncommonTables() finds the data difference in $source_tables_uncommon
*
* @param $source_tables_uncommon array of table names; containing table names that are in source db and not in target db
* @param $src_db name of source database
* @param $src_link connection established with source server
* @param $index index of a table from $matching_table array
* @param $row_count number of rows
* @return nothing
* @param array $source_tables_uncommon table names that are in source db and not in target db
* @param string $src_db name of source database
* @param mixed $src_link connection established with source server
* @param int $index index of a table from $matching_table array
* @param array $row_count number of rows
*/
function PMA_dataDiffInUncommonTables($source_tables_uncommon, $src_db, $src_link, $index, &$row_count)
{
@ -390,16 +380,15 @@ function PMA_dataDiffInUncommonTables($source_tables_uncommon, $src_db, $src_lin
* PMA_updateTargetTables() sets the updated field values to target table rows using $update_array[$matching_table_index]
*
*
* @param $table Array containing matching tables' names
* @param $update_array A three dimensional array containing field
* value updates required for each matching table
* @param $src_db Name of source database
* @param $trg_db Name of target database
* @param $trg_link Connection established with target server
* @param $matching_table_index index of matching table in matching_table_array
* @param $matching_table_keys
* @param $display true/false value
* @return nothing
* @param array $table Matching tables' names
* @param array $update_array A three dimensional array containing field
* value updates required for each matching table
* @param string $src_db Name of source database
* @param string $trg_db Name of target database
* @param mixed $trg_link Connection established with target server
* @param int $matching_table_index index of matching table in matching_table_array
* @param array $matching_table_keys
* @param boolean $display
*/
function PMA_updateTargetTables($table, $update_array, $src_db, $trg_db, $trg_link, $matching_table_index, $matching_table_keys, $display)
{
@ -433,6 +422,7 @@ function PMA_updateTargetTables($table, $update_array, $src_db, $trg_db, $trg_li
}
}
}
$query .= ';';
if ($display == true) {
echo "<p>" . $query . "</p>";
}
@ -447,34 +437,36 @@ function PMA_updateTargetTables($table, $update_array, $src_db, $trg_db, $trg_li
/**
* PMA_insertIntoTargetTable() inserts missing rows in the target table using $array_insert[$matching_table_index]
*
* @param $matching_table array containing matching table names
* @param $src_db name of source database
* @param $trg_db name of target database
* @param $src_link connection established with source server
* @param $trg_link connection established with target server
* @param $table_fields array containing field names of a table
* @param $array_insert
* @param $matching_table_index index of matching table in matching_table_array
* @param $matching_tables_keys array containing field names that are keys in the matching table
* @param $source_columns array containing source column information
* @param $add_column_array array containing column names that are to be added in target table
* @param $criteria array containing criterias like type, null, collation, default etc
* @param $target_tables_keys array containing field names that are keys in the target table
* @param $uncommon_tables array containing table names that are present in source db but not in targt db
* @param $uncommon_tables_fields array containing field names of the uncommon tables
* @param $uncommon_cols column names that are present in target table and not in source table
* @param $alter_str_array array containing column names that are to be altered
* @param $source_indexes column names on which indexes are made in source table
* @param $target_indexes column names on which indexes are made in target table
* @param $add_indexes_array array containing column names on which index is to be added in target table
* @param $alter_indexes_array array containing column names whose indexes are to be altered. Only index name and uniqueness of an index can be changed
* @param $delete_array array containing rows that are to be deleted
* @param $update_array array containing rows that are to be updated in target
* @param $display true/false value
* @return nothing
* @todo this function uses undefined variables and is possibly broken: $matching_tables,
* $matching_tables_fields, $remove_indexes_array, $matching_table_keys
*
* @param array $matching_table matching table names
* @param string $src_db name of source database
* @param string $trg_db name of target database
* @param mixed $src_link connection established with source server
* @param mixed $trg_link connection established with target server
* @param array $table_fields field names of a table
* @param array &$array_insert
* @param int $matching_table_index index of matching table in matching_table_array
* @param array $matching_tables_keys field names that are keys in the matching table
* @param array $source_columns source column information
* @param array &$add_column_array column names that are to be added in target table
* @param array $criteria criteria like type, null, collation, default etc
* @param array $target_tables_keys field names that are keys in the target table
* @param array $uncommon_tables table names that are present in source db but not in targt db
* @param array &$uncommon_tables_fields field names of the uncommon tables
* @param array $uncommon_cols column names that are present in target table and not in source table
* @param array &$alter_str_array column names that are to be altered
* @param array &$source_indexes column names on which indexes are made in source table
* @param array &$target_indexes column names on which indexes are made in target table
* @param array &$add_indexes_array column names on which index is to be added in target table
* @param array &$alter_indexes_array column names whose indexes are to be altered. Only index name and uniqueness of an index can be changed
* @param array &$delete_array rows that are to be deleted
* @param array &$update_array rows that are to be updated in target
* @param bool $display
*/
function PMA_insertIntoTargetTable($matching_table, $src_db, $trg_db, $src_link, $trg_link, $table_fields, &$array_insert, $matching_table_index,
$matching_tables_keys, $source_columns, &$add_column_array, $criteria, $target_tables_keys, $uncommon_tables, &$uncommon_tables_fields,$uncommon_cols,
$matching_tables_keys, $source_columns, &$add_column_array, $criteria, $target_tables_keys, $uncommon_tables, &$uncommon_tables_fields, $uncommon_cols,
&$alter_str_array,&$source_indexes, &$target_indexes, &$add_indexes_array, &$alter_indexes_array, &$delete_array, &$update_array, $display)
{
if (isset($array_insert[$matching_table_index])) {
@ -587,15 +579,14 @@ function PMA_insertIntoTargetTable($matching_table, $src_db, $trg_db, $src_link,
/**
* PMA_createTargetTables() Create the missing table $uncommon_table in target database
*
* @param $src_db name of source database
* @param $trg_db name of target database
* @param $src_link connection established with source server
* @param $trg_link connection established with target server
* @param $uncommon_tables names of tables present in source but not in target
* @param $table_index index of table in $uncommon_tables array
* @param $uncommon_tables_fields field names of the uncommon table
* @param $display true/false value
* @return nothing
* @param string $src_db name of source database
* @param string $trg_db name of target database
* @param mixed $src_link connection established with source server
* @param mixed $trg_link connection established with target server
* @param array &$uncommon_tables names of tables present in source but not in target
* @param int $table_index index of table in $uncommon_tables array
* @param array &$uncommon_tables_fields field names of the uncommon table
* @param bool $display
*/
function PMA_createTargetTables($src_db, $trg_db, $src_link, $trg_link, &$uncommon_tables, $table_index, &$uncommon_tables_fields, $display)
{
@ -631,6 +622,7 @@ function PMA_createTargetTables($src_db, $trg_db, $src_link, $trg_link, &$uncomm
}
}
}
$Create_Table_Query .= ';';
if ($display == true) {
echo '<p>' . $Create_Table_Query . '</p>';
}
@ -640,16 +632,14 @@ function PMA_createTargetTables($src_db, $trg_db, $src_link, $trg_link, &$uncomm
/**
* PMA_populateTargetTables() inserts data into uncommon tables after they have been created
*
* @param $src_db name of source database
* @param $trg_db name of target database
* @param $src_link connection established with source server
* @param $trg_link connection established with target server
* @param $uncommon_tables array containing uncommon table names (table names that are present in source but not in target db)
* @param $table_index index of table in matching_table_array
* @param $uncommon_tables_fields field names of the uncommon table
* @param $display true/false value
*
* @return nothing
* @param string $src_db name of source database
* @param string $trg_db name of target database
* @param mixed $src_link connection established with source server
* @param mixed $trg_link connection established with target server
* @param array $uncommon_tables uncommon table names (table names that are present in source but not in target db)
* @param int $table_index index of table in matching_table_array
* @param array $uncommon_tables_fields field names of the uncommon table
* @param bool $display
*
* @todo This turns NULL values into '' (empty string)
*/
@ -682,14 +672,13 @@ function PMA_populateTargetTables($src_db, $trg_db, $src_link, $trg_link, $uncom
/**
* PMA_deleteFromTargetTable() delete rows from target table
*
* @param $trg_db name of target database
* @param $trg_link connection established with target server
* @param $matching_tables array containing matching table names
* @param $table_index index of table in matching_table_array
* @param $target_tables_keys primary key names of the target tables
* @param $delete_array array containing the key values of rows that are to be deleted
* @param $display true/false value
* @return nothing
* @param string $trg_db name of target database
* @param mixed $trg_link connection established with target server
* @param array $matching_tables matching table names
* @param int $table_index index of table in matching_table_array
* @param array $target_tables_keys primary key names of the target tables
* @param array $delete_array key values of rows that are to be deleted
* @param bool $display
*/
function PMA_deleteFromTargetTable($trg_db, $trg_link, $matching_tables, $table_index, $target_tables_keys, $delete_array, $display)
{
@ -739,22 +728,21 @@ function PMA_deleteFromTargetTable($trg_db, $trg_link, $matching_tables, $table_
* Keys for all the source tables that have a corresponding target table are placed in $matching_tables_keys.
* Keys for all the target tables that have a corresponding source table are placed in $target_tables_keys.
*
* @param $src_db name of source database
* @param $trg_db name of target database
* @param $src_link connection established with source server
* @param $trg_link connection established with target server
* @param $matching_tables array containing names of matching tables
* @param $source_columns array containing columns information of the source tables
* @param $target_columns array containing columns information of the target tables
* @param $alter_str_array three dimensional associative array first index being the matching table index, second index being column name for which target
* column have some criteria different and third index containing the criteria which is different.
* @param $add_column_array two dimensional associative array, first index of the array contain the matching table number and second index contain the
* column name which is to be added in the target table
* @param $uncommon_columns array containing the columns that are present in the target table but not in the source table
* @param $criteria array containing the criterias which are to be checked for field that is present in source table and target table
* @param $target_tables_keys array containing the field names which is key in the target table
* @param $matching_table_index integer number of the matching table
* @return nothing
* @param string $src_db name of source database
* @param string $trg_db name of target database
* @param mixed $src_link connection established with source server
* @param mixed $trg_link connection established with target server
* @param array $matching_tables names of matching tables
* @param array &$source_columns columns information of the source tables
* @param array &$target_columns columns information of the target tables
* @param array &$alter_str_array three dimensional associative array first index being the matching table index, second index being column name for which target
* column have some criteria different and third index containing the criteria which is different.
* @param array &$add_column_array two dimensional associative array, first index of the array contain the matching table number and second index contain the
* column name which is to be added in the target table
* @param array &$uncommon_columns columns that are present in the target table but not in the source table
* @param array $criteria criteria which are to be checked for field that is present in source table and target table
* @param array &$target_tables_keys field names which is key in the target table
* @param int $matching_table_index number of the matching table
*/
function PMA_structureDiffInTables($src_db, $trg_db, $src_link, $trg_link, $matching_tables, &$source_columns, &$target_columns, &$alter_str_array,
&$add_column_array, &$uncommon_columns, $criteria, &$target_tables_keys, $matching_table_index)
@ -764,7 +752,7 @@ function PMA_structureDiffInTables($src_db, $trg_db, $src_link, $trg_link, $matc
$target_columns[$matching_table_index] = PMA_DBI_get_columns_full($trg_db, $matching_tables[$matching_table_index], null, $trg_link);
foreach ($source_columns[$matching_table_index] as $column_name => $each_column) {
if (isset($target_columns[$matching_table_index][$column_name]['Field'])) {
//If column exists in target table then matches criterias like type, null, collation, key, default, comment of the column
//If column exists in target table then matches criteria like type, null, collation, key, default, comment of the column
for ($i = 0; $i < sizeof($criteria); $i++) {
if ($source_columns[$matching_table_index][$column_name][$criteria[$i]] != $target_columns[$matching_table_index][$column_name][$criteria[$i]]) {
if (($criteria[$i] == 'Default') && ($source_columns[$matching_table_index][$column_name][$criteria[$i]] == '' )) {
@ -802,23 +790,22 @@ function PMA_structureDiffInTables($src_db, $trg_db, $src_link, $trg_link, $matc
/**
* PMA_addColumnsInTargetTable() adds column that are present in source table but not in target table
*
* @param $src_db name of source database
* @param $trg_db name of target database
* @param $src_link connection established with source server
* @param $trg_link connection established with target server
* @param $matching_tables array containing names of matching tables
* @param $source_columns array containing columns information of the source tables
* @param $add_column_array array containing the names of the column(field) that are to be added in the target
* @param $matching_tables_fields
* @param $criteria array containing the criterias
* @param $matching_tables_keys array containing the field names which is key in the source table
* @param $target_tables_keys array containing the field names which is key in the target table
* @param $uncommon_tables array containing the table names that are present in source db and not in target db
* @param $uncommon_tables_fields array containing the names of the fields of the uncommon tables
* @param $table_counter integer number of the matching table
* @param $uncommon_cols
* @param $display true/false value
* @return nothing
* @param string $src_db name of source database
* @param string $trg_db name of target database
* @param mixed $src_link connection established with source server
* @param mixed $trg_link connection established with target server
* @param array $matching_tables names of matching tables
* @param array $source_columns columns information of the source tables
* @param array &$add_column_array the names of the column(field) that are to be added in the target
* @param array $matching_tables_fields
* @param array $criteria criteria
* @param array $matching_tables_keys field names which is key in the source table
* @param array $target_tables_keys field names which is key in the target table
* @param array $uncommon_tables table names that are present in source db and not in target db
* @param array &$uncommon_tables_fields names of the fields of the uncommon tables
* @param int $table_counter number of the matching table
* @param array $uncommon_cols
* @param bool $display
*/
function PMA_addColumnsInTargetTable($src_db, $trg_db, $src_link, $trg_link, $matching_tables, $source_columns, &$add_column_array, $matching_tables_fields,
$criteria, $matching_tables_keys, $target_tables_keys, $uncommon_tables, &$uncommon_tables_fields, $table_counter, $uncommon_cols, $display)
@ -883,8 +870,8 @@ function PMA_addColumnsInTargetTable($src_db, $trg_db, $src_link, $trg_link, $ma
if (isset($is_fk_result)) {
if (in_array($is_fk_result[0]['REFERENCED_TABLE_NAME'], $uncommon_tables)) {
$table_index = array_keys($uncommon_tables, $is_fk_result[0]['REFERENCED_TABLE_NAME']);
PMA_checkForeignKeys($src_db, $src_link, $trg_db, $trg_link, $is_fk_result[0]['REFERENCED_TABLE_NAME'], $uncommon_tables, $uncommon_tables_fields);
PMA_createTargetTables($src_db, $trg_db, $trg_link, $src_link, $uncommon_tables, $table_index[0], $uncommon_tables_fields);
PMA_checkForeignKeys($src_db, $src_link, $trg_db, $trg_link, $is_fk_result[0]['REFERENCED_TABLE_NAME'], $uncommon_tables, $uncommon_tables_fields, $display);
PMA_createTargetTables($src_db, $trg_db, $trg_link, $src_link, $uncommon_tables, $table_index[0], $uncommon_tables_fields, $display);
unset($uncommon_tables[$table_index[0]]);
}
$fk_query = "ALTER TABLE " . PMA_backquote($trg_db) . '.' . PMA_backquote($matching_tables[$table_counter]) .
@ -901,17 +888,16 @@ function PMA_addColumnsInTargetTable($src_db, $trg_db, $src_link, $trg_link, $ma
* PMA_checkForeignKeys() checks if the referenced table have foreign keys.
* uses PMA_createTargetTables()
*
* @param $src_db name of source database
* @param $src_link connection established with source server
* @param $trg_db name of target database
* @param $trg_link connection established with target server
* @param $referenced_table table whose column is a foreign key in another table
* @param $uncommon_tables array containing names that are uncommon
* @param $uncommon_tables_fields field names of the uncommon table
* @param $display true/false value
* @return nothing
* @param string $src_db name of source database
* @param mixed $src_link connection established with source server
* @param string $trg_db name of target database
* @param mixed $trg_link connection established with target server
* @param string $referenced_table table whose column is a foreign key in another table
* @param array &$uncommon_tables names that are uncommon
* @param array &$uncommon_tables_fields field names of the uncommon table
* @param bool $display
*/
function PMA_checkForeignKeys($src_db, $src_link, $trg_db, $trg_link ,$referenced_table, &$uncommon_tables, &$uncommon_tables_fields, $display)
function PMA_checkForeignKeys($src_db, $src_link, $trg_db, $trg_link, $referenced_table, &$uncommon_tables, &$uncommon_tables_fields, $display)
{
$is_fk_query = "SELECT * FROM information_schema.KEY_COLUMN_USAGE WHERE TABLE_SCHEMA = '" . $src_db . "'
AND TABLE_NAME = '" . $referenced_table . "' AND TABLE_NAME <> REFERENCED_TABLE_NAME;";
@ -932,18 +918,17 @@ function PMA_checkForeignKeys($src_db, $src_link, $trg_db, $trg_link ,$reference
/**
* PMA_alterTargetTableStructure() alters structure of the target table using $alter_str_array
*
* @param $trg_db name of target database
* @param $trg_link connection established with target server
* @param $matching_tables array containing names of matching tables
* @param $source_columns array containing columns information of the source table
* @param $alter_str_array array containing the column name and criteria which is to be altered for the targert table
* @param $matching_tables_fields array containing the name of the fields for the matching table
* @param $criteria array containing the criterias
* @param $matching_tables_keys array containing the field names which is key in the source table
* @param $target_tables_keys array containing the field names which is key in the target table
* @param $matching_table_index integer number of the matching table
* @param $display true/false value
* @return nothing
* @param string $trg_db name of target database
* @param mixed $trg_link connection established with target server
* @param array $matching_tables names of matching tables
* @param array &$source_columns columns information of the source table
* @param array &$alter_str_array column name and criteria which is to be altered for the targert table
* @param array $matching_tables_fields name of the fields for the matching table
* @param array $criteria criteria
* @param array &$matching_tables_keys field names which is key in the source table
* @param array &$target_tables_keys field names which is key in the target table
* @param int $matching_table_index number of the matching table
* @param bool $display
*/
function PMA_alterTargetTableStructure($trg_db, $trg_link, $matching_tables, &$source_columns, &$alter_str_array, $matching_tables_fields, $criteria,
&$matching_tables_keys, &$target_tables_keys, $matching_table_index, $display)
@ -960,7 +945,8 @@ function PMA_alterTargetTableStructure($trg_db, $trg_link, $matching_tables, &$s
}
}
}
$pri_query;
$pri_query = null;
if (! $check) {
$pri_query = "ALTER TABLE " . PMA_backquote($trg_db) . '.' . PMA_backquote($matching_tables[$matching_table_index]);
if (sizeof($target_tables_keys[$matching_table_index]) > 0) {
@ -1056,6 +1042,7 @@ function PMA_alterTargetTableStructure($trg_db, $trg_link, $matching_tables, &$s
}
}
}
$query .= ';';
if ($check) {
if ($display == true) {
echo '<p>' . $query . '</p>';
@ -1067,13 +1054,12 @@ function PMA_alterTargetTableStructure($trg_db, $trg_link, $matching_tables, &$s
/**
* PMA_removeColumnsFromTargetTable() removes the columns which are present in target table but not in source table.
*
* @param $trg_db name of target database
* @param $trg_link connection established with target server
* @param $matching_tables array containing names of matching tables
* @param $uncommon_columns array containing the names of the column which are to be dropped from the target table
* @param $table_counter index of the matching table as in $matchiing_tables array
* @param $display true/false value
* @return nothing
* @param string $trg_db name of target database
* @param mixed $trg_link connection established with target server
* @param array $matching_tables names of matching tables
* @param array $uncommon_columns array containing the names of the column which are to be dropped from the target table
* @param int $table_counter index of the matching table as in $matchiing_tables array
* @param bool $display
*/
function PMA_removeColumnsFromTargetTable($trg_db, $trg_link, $matching_tables, $uncommon_columns, $table_counter, $display)
{
@ -1123,18 +1109,17 @@ function PMA_removeColumnsFromTargetTable($trg_db, $trg_link, $matching_tables,
* indexes to be altered in $alter_indexes_array and indexes to be removed from target table in $remove_indexes_array.
* Only keyname and uniqueness characteristic of the indexes are altered.
*
* @param $src_db name of source database
* @param $trg_db name of target database
* @param $src_link connection established with source server
* @param $trg_link connection established with target server
* @param $matching_tables array containing the matching tables name
* @param $source_indexes array containing the indexes of the source table
* @param $target_indexes array containing the indexes of the target table
* @param $add_indexes_array array containing the name of the column on which the index is to be added in the target table
* @param $alter_indexes_array array containing the key name which needs to be altered
* @param $remove_indexes_array array containing the key name of the index which is to be removed from the target table
* @param $table_counter number of the matching table
* @return nothing
* @param string $src_db name of source database
* @param string $trg_db name of target database
* @param mixed $src_link connection established with source server
* @param mixed $trg_link connection established with target server
* @param array $matching_tables matching tables name
* @param array &$source_indexes indexes of the source table
* @param array &$target_indexes indexes of the target table
* @param array &$add_indexes_array name of the column on which the index is to be added in the target table
* @param array &$alter_indexes_array key name which needs to be altered
* @param array &$remove_indexes_array key name of the index which is to be removed from the target table
* @param int $table_counter number of the matching table
*/
function PMA_indexesDiffInTables($src_db, $trg_db, $src_link, $trg_link, $matching_tables, &$source_indexes, &$target_indexes, &$add_indexes_array,
&$alter_indexes_array, &$remove_indexes_array, $table_counter)
@ -1188,17 +1173,16 @@ function PMA_indexesDiffInTables($src_db, $trg_db, $src_link, $trg_link, $matchi
/**
* PMA_applyIndexesDiff() create indexes, alters indexes and remove indexes.
*
* @param $trg_db name of target database
* @param $trg_link connection established with target server
* @param $matching_tables array containing the matching tables name
* @param $source_indexes array containing the indexes of the source table
* @param $target_indexes array containing the indexes of the target table
* @param $add_indexes_array array containing the column names on which indexes are to be created in target table
* @param $alter_indexes_array array containing the column names for which indexes are to be altered
* @param $remove_indexes_array array containing the key name of the indexes which are to be removed from the target table
* @param $table_counter number of the matching table
* @param $display true/false value
* @return nothing
* @param string $trg_db name of target database
* @param mixed $trg_link connection established with target server
* @param array $matching_tables matching tables name
* @param array $source_indexes indexes of the source table
* @param array $target_indexes indexes of the target table
* @param array $add_indexes_array column names on which indexes are to be created in target table
* @param array $alter_indexes_array column names for which indexes are to be altered
* @param array $remove_indexes_array key name of the indexes which are to be removed from the target table
* @param int $table_counter number of the matching table
* @param $display
*/
function PMA_applyIndexesDiff ($trg_db, $trg_link, $matching_tables, $source_indexes, $target_indexes, $add_indexes_array, $alter_indexes_array,
$remove_indexes_array, $table_counter, $display)
@ -1248,6 +1232,7 @@ function PMA_applyIndexesDiff ($trg_db, $trg_link, $matching_tables, $source_ind
$query .= " )";
}
}
$query .= ';';
if ($display == true) {
echo '<p>' . $query . '</p>';
}
@ -1276,10 +1261,10 @@ function PMA_applyIndexesDiff ($trg_db, $trg_link, $matching_tables, $source_ind
* PMA_displayQuery() displays a query, taking the maximum display size
* into account
*
* @param $query the query to display
* @return nothing
* @param string $query the query to display
*/
function PMA_displayQuery($query) {
function PMA_displayQuery($query)
{
if (strlen($query) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
$query = substr($query, 0, $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) . '[...]';
}
@ -1291,9 +1276,9 @@ function PMA_displayQuery($query) {
*
* @param string $src_db source db name
* @param string $trg_db target db name
* @return nothing
*/
function PMA_syncDisplayHeaderCompare($src_db, $trg_db) {
function PMA_syncDisplayHeaderCompare($src_db, $trg_db)
{
echo '<fieldset style="padding:0"><div style="padding:1.5em; overflow:auto; height:220px">';
echo '<table class="data">';
@ -1328,7 +1313,8 @@ function PMA_syncDisplayHeaderCompare($src_db, $trg_db) {
*
* @param array $rows
*/
function PMA_syncDisplayDataCompare($rows) {
function PMA_syncDisplayDataCompare($rows)
{
global $pmaThemeImage;
$odd_row = true;
@ -1397,13 +1383,12 @@ function PMA_get_column_values($database, $table, $column, $link = null)
*/
function PMA_get_table_indexes($database, $table, $link = null)
{
$indexes = PMA_DBI_fetch_result(
'SHOW INDEXES FROM ' .PMA_backquote($database) . '.' . PMA_backquote($table),
null, null, $link);
if (! is_array($indexes) || count($indexes) < 1) {
return false;
if (!is_array($indexes) || count($indexes) == 0) {
return null;
}
return $indexes;
}

View File

@ -970,7 +970,8 @@ $VARIABLE_DOC_LINKS['query_alloc_block_size'] = array(
$VARIABLE_DOC_LINKS['query_cache_limit'] = array(
'query_cache_limit',
'server-system-variables',
'sysvar');
'sysvar',
'byte');
$VARIABLE_DOC_LINKS['query_cache_min_res_unit'] = array(
'query_cache_min_res_unit',
'server-system-variables',

View File

@ -110,7 +110,7 @@ function PMA_sqlQueryForm($query = true, $display_tab = false, $delimiter = ';')
.'<input type="hidden" name="goto" value="'
.htmlspecialchars($goto) . '" />' . "\n"
.'<input type="hidden" name="message_to_show" value="'
. htmlspecialchars(__('Your SQL query has been executed successfully')) . '" />' . "\n"
. __('Your SQL query has been executed successfully') . '" />' . "\n"
.'<input type="hidden" name="prev_sql_query" value="'
. htmlspecialchars($query) . '" />' . "\n";
@ -420,7 +420,8 @@ function PMA_sqlQueryFormBookmark()
*
* @usedby PMA_sqlQueryForm()
*/
function PMA_sqlQueryFormUpload() {
function PMA_sqlQueryFormUpload()
{
$errors = array ();
$matcher = '@\.sql(\.(' . PMA_supportedDecompressions() . '))?$@'; // we allow only SQL here

View File

@ -1,15 +1,16 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Library for extracting information about system memory and cpu. Currently supports all
* Library for extracting information about system memory and cpu. Currently supports all
* Windows and Linux plattforms
*
* This code is based on the OS Classes from the phpsysinfo project (http://phpsysinfo.sourceforge.net/)
*
*
* @package phpMyAdmin
*/
function getSysInfo() {
function getSysInfo()
{
$supported = array('Linux','WINNT');
$sysinfo = array();
@ -17,14 +18,15 @@ function getSysInfo() {
if (in_array(PHP_OS, $supported)) {
return eval("return new ".PHP_OS."();");
}
return $sysinfo;
}
class WINNT {
class WINNT
{
private $_wmi;
public $os = 'WINNT';
public function __construct() {
@ -37,20 +39,20 @@ class WINNT {
$loadavg = "";
$sum = 0;
$buffer = $this->_getWMI('Win32_Processor', array('LoadPercentage'));
foreach ($buffer as $load) {
$value = $load['LoadPercentage'];
$loadavg .= $value.' ';
$sum += $value;
}
return array('loadavg' => $sum / count($buffer));
}
private function _getWMI($strClass, $strValue = array()) {
$arrData = array();
$value = "";
$objWEBM = $this->_wmi->Get($strClass);
$arrProp = $objWEBM->Properties_;
$arrWEBMCol = $objWEBM->Instances_();
@ -75,49 +77,50 @@ class WINNT {
return $arrData;
}
function memory() {
$buffer = $this->_getWMI("Win32_OperatingSystem", array('TotalVisibleMemorySize', 'FreePhysicalMemory'));
$mem = Array();
$mem['MemTotal'] = $buffer[0]['TotalVisibleMemorySize'];
$mem['MemFree'] = $buffer[0]['FreePhysicalMemory'];
$mem['MemUsed'] = $mem['MemTotal'] - $mem['MemFree'];
$buffer = $this->_getWMI('Win32_PageFileUsage');
$mem['SwapTotal'] = 0;
$mem['SwapUsed'] = 0;
$mem['SwapPeak'] = 0;
foreach ($buffer as $swapdevice) {
$mem['SwapTotal'] += $swapdevice['AllocatedBaseSize'] * 1024;
$mem['SwapUsed'] += $swapdevice['CurrentUsage'] * 1024;
$mem['SwapPeak'] += $swapdevice['PeakUsage'] * 1024;
}
return $mem;
}
}
class Linux {
class Linux
{
public $os = 'Linux';
function loadavg() {
$buf = file_get_contents('/proc/stat');
$nums=preg_split("/\s+/", substr($buf,0,strpos($buf,"\n")));
return Array('busy' => $nums[1]+$nums[2]+$nums[3], 'idle' => intval($nums[4]));
}
function memory() {
preg_match_all('/^(MemTotal|MemFree|Cached|Buffers|SwapCached|SwapTotal|SwapFree):\s+(.*)\s*kB/im', file_get_contents('/proc/meminfo'), $matches);
$mem = array_combine( $matches[1], $matches[2] );
$mem['MemUsed'] = $mem['MemTotal'] - $mem['MemFree'] - $mem['Cached'] - $mem['Buffers'];
$mem['SwapUsed'] = $mem['SwapTotal'] - $mem['SwapFree'] - $mem['SwapCached'];
foreach ($mem as $idx=>$value)
foreach ($mem as $idx=>$value)
$mem[$idx] = intval($value);
return $mem;
}
}

View File

@ -298,11 +298,7 @@ for ($i = 0; $i < $num_fields; $i++) {
if ('set' == $extracted_fieldspec['type'] || 'enum' == $extracted_fieldspec['type']) {
$length = $extracted_fieldspec['spec_in_brackets'];
} else {
// strip the "BINARY" attribute, except if we find "BINARY(" because
// this would be a BINARY or VARBINARY field type
$type = preg_replace('@BINARY([^\(])@i', '', $type);
$type = preg_replace('@ZEROFILL@i', '', $type);
$type = preg_replace('@UNSIGNED@i', '', $type);
$type = $extracted_fieldspec['print_type'];
$length = $extracted_fieldspec['spec_in_brackets'];
} // end if else
} else {
@ -336,15 +332,6 @@ for ($i = 0; $i < $num_fields; $i++) {
}
// column length
if (isset($extracted_fieldspec) && ('set' == $extracted_fieldspec['type'] || 'enum' == $extracted_fieldspec['type'])) {
$binary = 0;
$unsigned = 0;
$zerofill = 0;
} else {
$binary = false;
$unsigned = stristr($row['Type'], 'unsigned');
$zerofill = stristr($row['Type'], 'zerofill');
}
$length_to_display = $length;
$content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
@ -425,15 +412,10 @@ for ($i = 0; $i < $num_fields; $i++) {
. ' id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
$attribute = '';
if ($binary) {
$attribute = 'BINARY';
}
if ($unsigned) {
$attribute = 'UNSIGNED';
}
if ($zerofill) {
$attribute = 'UNSIGNED ZEROFILL';
if (isset($extracted_fieldspec)) {
$attribute = $extracted_fieldspec['attribute'];
}
if (isset($row['Extra']) && $row['Extra'] == 'on update CURRENT_TIMESTAMP') {
$attribute = 'on update CURRENT_TIMESTAMP';
}
@ -688,7 +670,8 @@ if ($display_type == 'horizontal') {
// <![CDATA[
var odd_row = <?php echo $odd_row; ?>;
function addField() {
function addField()
{
var new_fields = document.getElementById('added_fields').value;
var new_field_container = document.getElementById('table_columns');
var new_field = '<?php echo preg_replace('|\s+|', ' ', preg_replace('|\'|', '\\\'', $new_field)); ?>';

View File

@ -11,13 +11,15 @@
* extension. For further information regarding naming conventions see the /Documentation.html file.
*/
function PMA_transformation_[ENTER_FILENAME_HERE]_info() {
function PMA_transformation_[ENTER_FILENAME_HERE]_info()
{
return array(
'info' => __('Description of the transformation.'),
);
}
function PMA_transformation_[ENTER_FILENAME_HERE]($buffer, $options = array(), $meta = '') {
function PMA_transformation_[ENTER_FILENAME_HERE]($buffer, $options = array(), $meta = '')
{
// possibly use a global transform and feed it with special options:
// include('./libraries/transformations/global.inc.php');

View File

@ -4,7 +4,8 @@
* @package phpMyAdmin-Transformation
*/
function PMA_transformation_application_octetstream__download_info() {
function PMA_transformation_application_octetstream__download_info()
{
return array(
'info' => __('Displays a link to download the binary data of the column. You can use the first option to specify the filename, or use the second option as the name of a column which contains the filename. If you use the second option, you need to set the first option to the empty string.'),
);
@ -13,7 +14,8 @@ function PMA_transformation_application_octetstream__download_info() {
/**
*
*/
function PMA_transformation_application_octetstream__download(&$buffer, $options = array(), $meta = '') {
function PMA_transformation_application_octetstream__download(&$buffer, $options = array(), $meta = '')
{
global $row, $fields_meta;
if (isset($options[0]) && !empty($options[0])) {

View File

@ -4,7 +4,8 @@
* @package phpMyAdmin-Transformation
*/
function PMA_transformation_application_octetstream__hex_info() {
function PMA_transformation_application_octetstream__hex_info()
{
return array(
'info' => __('Displays hexadecimal representation of data. Optional first parameter specifies how often space will be added (defaults to 2 nibbles).'),
);
@ -13,7 +14,8 @@ function PMA_transformation_application_octetstream__hex_info() {
/**
*
*/
function PMA_transformation_application_octetstream__hex($buffer, $options = array(), $meta = '') {
function PMA_transformation_application_octetstream__hex($buffer, $options = array(), $meta = '')
{
// possibly use a global transform and feed it with special options:
// include './libraries/transformations/global.inc.php';
if (!isset($options[0])) {

View File

@ -25,15 +25,18 @@
/**
*
*/
function PMA_transformation_global_plain($buffer, $options = array(), $meta = '') {
function PMA_transformation_global_plain($buffer, $options = array(), $meta = '')
{
return htmlspecialchars($buffer);
}
function PMA_transformation_global_html($buffer, $options = array(), $meta = '') {
function PMA_transformation_global_html($buffer, $options = array(), $meta = '')
{
return $buffer;
}
function PMA_transformation_global_html_replace($buffer, $options = array(), $meta = '') {
function PMA_transformation_global_html_replace($buffer, $options = array(), $meta = '')
{
if (!isset($options['string'])) {
$options['string'] = '';
}

View File

@ -4,7 +4,8 @@
* @package phpMyAdmin-Transformation
*/
function PMA_transformation_image_jpeg__inline_info() {
function PMA_transformation_image_jpeg__inline_info()
{
return array(
'info' => __('Displays a clickable thumbnail. The options are the maximum width and height in pixels. The original aspect ratio is preserved.'),
);
@ -13,7 +14,8 @@ function PMA_transformation_image_jpeg__inline_info() {
/**
*
*/
function PMA_transformation_image_jpeg__inline($buffer, $options = array(), $meta = '') {
function PMA_transformation_image_jpeg__inline($buffer, $options = array(), $meta = '')
{
require_once './libraries/transformations/global.inc.php';
if (PMA_IS_GD2) {

View File

@ -4,7 +4,8 @@
* @package phpMyAdmin-Transformation
*/
function PMA_transformation_image_jpeg__link_info() {
function PMA_transformation_image_jpeg__link_info()
{
return array(
'info' => __('Displays a link to download this image.'),
);
@ -13,7 +14,8 @@ function PMA_transformation_image_jpeg__link_info() {
/**
*
*/
function PMA_transformation_image_jpeg__link($buffer, $options = array(), $meta = '') {
function PMA_transformation_image_jpeg__link($buffer, $options = array(), $meta = '')
{
require_once './libraries/transformations/global.inc.php';
$transform_options = array ('string' => '<a href="transformation_wrapper.php' . $options['wrapper_link'] . '" alt="[__BUFFER__]">[BLOB]</a>');

Some files were not shown because too many files have changed in this diff Show More