本文整理汇总了PHP中PMA_Util类的典型用法代码示例。如果您正苦于以下问题:PHP PMA_Util类的具体用法?PHP PMA_Util怎么用?PHP PMA_Util使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PMA_Util类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPMASelectServer
/**
* Test for PMA_selectServer
*
* @return void
*/
public function testPMASelectServer()
{
$not_only_options = false;
$omit_fieldset = false;
$GLOBALS['cfg']['DefaultTabServer'] = "welcome";
$GLOBALS['cfg']['Servers'] = array('0' => array('host' => 'host0', 'port' => 'port0', 'only_db' => 'only_db0', 'user' => 'user0', 'auth_type' => 'config'), '1' => array('host' => 'host1', 'port' => 'port1', 'only_db' => 'only_db1', 'user' => 'user1', 'auth_type' => 'config'));
//$not_only_options=false & $omit_fieldset=false
$html = PMA_selectServer($not_only_options, $omit_fieldset);
$server = $GLOBALS['cfg']['Servers']['0'];
//server items
$this->assertContains($server['host'], $html);
$this->assertContains($server['port'], $html);
$this->assertContains($server['only_db'], $html);
$this->assertContains($server['user'], $html);
$not_only_options = true;
$omit_fieldset = true;
$GLOBALS['cfg']['DisplayServersList'] = null;
//$not_only_options=true & $omit_fieldset=true
$html = PMA_selectServer($not_only_options, $omit_fieldset);
//$GLOBALS['cfg']['DefaultTabServer']
$this->assertContains(PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabServer'], 'server'), $html);
//labels
$this->assertContains(__('Current Server:'), $html);
$this->assertContains('(' . __('Servers') . ')', $html);
//server items
$server = $GLOBALS['cfg']['Servers']['0'];
$this->assertContains($server['host'], $html);
$this->assertContains($server['port'], $html);
$this->assertContains($server['only_db'], $html);
$this->assertContains($server['user'], $html);
}
示例2: testNotSupportedDataTypes
function testNotSupportedDataTypes()
{
$no_support_types = array();
$this->assertEquals(
$no_support_types, PMA_Util::unsupportedDatatypes()
);
}
示例3: testConvert_bit_default_value_test
/**
* @dataProvider dataProvider
*/
function testConvert_bit_default_value_test($bit, $val)
{
$this->assertEquals(
$val, PMA_Util::convertBitDefaultValue($bit)
);
}
示例4: testExtractValueFromFormattedSizeK
function testExtractValueFromFormattedSizeK()
{
$this->assertEquals(
262144,
PMA_Util::extractValueFromFormattedSize("256K")
);
}
示例5: PMA_getHtmlForSubPageHeader
/**
* Returns the html for the sub-page heading
*
* @param string $type Sub page type
* @param string $link Link to the official MySQL documentation
* @param bool $is_image Display image or icon, true: image, false: icon
*
* @return string
*/
function PMA_getHtmlForSubPageHeader($type, $link = '', $is_image = true)
{
//array contains Sub page icon and text
$header = array();
$header['variables']['image'] = 's_vars.png';
$header['variables']['text'] = __('Server variables and settings');
$header['engines']['image'] = 'b_engine.png';
$header['engines']['text'] = __('Storage Engines');
$header['plugins']['image'] = 'b_engine.png';
$header['plugins']['text'] = __('Plugins');
$header['binlog']['image'] = 's_tbl.png';
$header['binlog']['text'] = __('Binary log');
$header['collations']['image'] = 's_asci.png';
$header['collations']['text'] = __('Character Sets and Collations');
$header['replication']['image'] = 's_replication.png';
$header['replication']['text'] = __('Replication');
$header['database_statistics']['image'] = 's_db.png';
$header['database_statistics']['text'] = __('Databases statistics');
$header['databases']['image'] = 's_db.png';
$header['databases']['text'] = __('Databases');
$header['privileges']['image'] = 'b_usrlist.png';
$header['privileges']['text'] = __('Privileges');
if ($is_image) {
$html = '<h2>' . "\n" . PMA_Util::getImage($header[$type]['image']) . ' ' . $header[$type]['text'] . "\n" . $link . '</h2>' . "\n";
} else {
$html = '<h2>' . "\n" . PMA_Util::getIcon($header[$type]['image']) . ' ' . $header[$type]['text'] . "\n" . $link . '</h2>' . "\n";
}
return $html;
}
示例6: PMA_saveUserprefs
/**
* Saves user preferences
*
* @param array $config_array configuration array
*
* @return true|PMA_Message
*/
function PMA_saveUserprefs(array $config_array)
{
$cfgRelation = PMA_getRelationsParam();
$server = isset($GLOBALS['server']) ? $GLOBALS['server'] : $GLOBALS['cfg']['ServerDefault'];
$cache_key = 'server_' . $server;
if (!$cfgRelation['userconfigwork']) {
// no pmadb table, use session storage
$_SESSION['userconfig'] = array('db' => $config_array, 'ts' => time());
if (isset($_SESSION['cache'][$cache_key]['userprefs'])) {
unset($_SESSION['cache'][$cache_key]['userprefs']);
}
return true;
}
// save configuration to pmadb
$query_table = PMA_Util::backquote($cfgRelation['db']) . '.' . PMA_Util::backquote($cfgRelation['userconfig']);
$query = 'SELECT `username` FROM ' . $query_table . ' WHERE `username` = \'' . PMA_Util::sqlAddSlashes($cfgRelation['user']) . '\'';
$has_config = $GLOBALS['dbi']->fetchValue($query, 0, 0, $GLOBALS['controllink']);
$config_data = json_encode($config_array);
if ($has_config) {
$query = 'UPDATE ' . $query_table . ' SET `timevalue` = NOW(), `config_data` = \'' . PMA_Util::sqlAddSlashes($config_data) . '\'' . ' WHERE `username` = \'' . PMA_Util::sqlAddSlashes($cfgRelation['user']) . '\'';
} else {
$query = 'INSERT INTO ' . $query_table . ' (`username`, `timevalue`,`config_data`) ' . 'VALUES (\'' . PMA_Util::sqlAddSlashes($cfgRelation['user']) . '\', NOW(), ' . '\'' . PMA_Util::sqlAddSlashes($config_data) . '\')';
}
if (isset($_SESSION['cache'][$cache_key]['userprefs'])) {
unset($_SESSION['cache'][$cache_key]['userprefs']);
}
if (!$GLOBALS['dbi']->tryQuery($query, $GLOBALS['controllink'])) {
$message = PMA_Message::error(__('Could not save configuration'));
$message->addMessage('<br /><br />');
$message->addMessage(PMA_Message::rawError($GLOBALS['dbi']->getError($GLOBALS['controllink'])));
return $message;
}
return true;
}
示例7: PMA_printGitRevision
/**
* Prints details about the current Git commit revision
*
* @return void
*/
function PMA_printGitRevision()
{
if (!$GLOBALS['PMA_Config']->get('PMA_VERSION_GIT')) {
$response = PMA_Response::getInstance();
$response->isSuccess(false);
return;
}
// load revision data from repo
$GLOBALS['PMA_Config']->checkGitRevision();
// if using a remote commit fast-forwarded, link to GitHub
$commit_hash = substr($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITHASH'), 0, 7);
$commit_hash = '<strong title="' . htmlspecialchars($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_MESSAGE')) . '">' . $commit_hash . '</strong>';
if ($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_ISREMOTECOMMIT')) {
$commit_hash = '<a href="' . PMA_linkURL('https://github.com/phpmyadmin/phpmyadmin/commit/' . $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITHASH')) . '" target="_blank">' . $commit_hash . '</a>';
}
$branch = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_BRANCH');
if ($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_ISREMOTEBRANCH')) {
$branch = '<a href="' . PMA_linkURL('https://github.com/phpmyadmin/phpmyadmin/tree/' . $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_BRANCH')) . '" target="_blank">' . $branch . '</a>';
}
if ($branch !== false) {
$branch = sprintf(__('%1$s from %2$s branch'), $commit_hash, $branch);
} else {
$branch = $commit_hash . ' (' . __('no branch') . ')';
}
$committer = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITTER');
$author = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_AUTHOR');
PMA_printListItem(__('Git revision:') . ' ' . $branch . ',<br /> ' . sprintf(__('committed on %1$s by %2$s'), PMA_Util::localisedDate(strtotime($committer['date'])), '<a href="' . PMA_linkURL('mailto:' . $committer['email']) . '">' . htmlspecialchars($committer['name']) . '</a>') . ($author != $committer ? ', <br />' . sprintf(__('authored on %1$s by %2$s'), PMA_Util::localisedDate(strtotime($author['date'])), '<a href="' . PMA_linkURL('mailto:' . $author['email']) . '">' . htmlspecialchars($author['name']) . '</a>') : ''), 'li_pma_version_git', null, null, null);
}
示例8: PMA_getHtmlForAdvisor
/**
* Returns html with Advisor
*
* @return string
*/
function PMA_getHtmlForAdvisor()
{
$output = '<a href="#openAdvisorInstructions">';
$output .= PMA_Util::getIcon('b_help.png', __('Instructions'));
$output .= '</a>';
$output .= '<div id="statustabs_advisor"></div>';
$output .= '<div id="advisorInstructionsDialog" style="display:none;">';
$output .= '<p>';
$output .= __('The Advisor system can provide recommendations ' . 'on server variables by analyzing the server status variables.');
$output .= '</p>';
$output .= '<p>';
$output .= __('Do note however that this system provides recommendations ' . 'based on simple calculations and by rule of thumb which may ' . 'not necessarily apply to your system.');
$output .= '</p>';
$output .= '<p>';
$output .= __('Prior to changing any of the configuration, be sure to know ' . 'what you are changing (by reading the documentation) and how ' . 'to undo the change. Wrong tuning can have a very negative ' . 'effect on performance.');
$output .= '</p>';
$output .= '<p>';
$output .= __('The best way to tune your system would be to change only one ' . 'setting at a time, observe or benchmark your database, and undo ' . 'the change if there was no clearly measurable improvement.');
$output .= '</p>';
$output .= '</div>';
$output .= '<div id="advisorData" style="display:none;">';
$advisor = new Advisor();
$output .= htmlspecialchars(json_encode($advisor->run()));
$output .= '</div>';
return $output;
}
示例9: testPMAGetHtmlForActionLinks
/**
* Test for PMA_getHtmlForActionLinks
*
* @return void
*/
public function testPMAGetHtmlForActionLinks()
{
$current_table = array('TABLE_ROWS' => 3, 'TABLE_NAME' => 'name1', 'TABLE_COMMENT' => 'This is a test comment');
$table_is_view = false;
$tbl_url_query = 'tbl_url_query';
$titles = array('Browse' => 'Browse1', 'NoBrowse' => 'NoBrowse1', 'Search' => 'Search1', 'NoSearch' => 'NoSearch1', 'Empty' => 'Empty1', 'NoEmpty' => 'NoEmpty1');
$truename = 'truename';
$db_is_system_schema = null;
$url_query = 'url_query';
//$table_is_view = true;
list($browse_table, $search_table, $browse_table_label, $empty_table, $tracking_icon) = PMA_getHtmlForActionLinks($current_table, $table_is_view, $tbl_url_query, $titles, $truename, $db_is_system_schema, $url_query);
//$browse_table
$this->assertContains($titles['Browse'], $browse_table);
//$search_table
$this->assertContains($titles['Search'], $search_table);
$this->assertContains($tbl_url_query, $search_table);
//$browse_table_label
$this->assertContains($tbl_url_query, $browse_table_label);
//$empty_table
$this->assertContains($tbl_url_query, $empty_table);
$this->assertContains(urlencode('TRUNCATE ' . PMA_Util::backquote($current_table['TABLE_NAME'])), $empty_table);
$this->assertContains($titles['Empty'], $empty_table);
//$table_is_view = false;
$current_table = array('TABLE_ROWS' => 0, 'TABLE_NAME' => 'name1', 'TABLE_COMMENT' => 'This is a test comment');
$table_is_view = false;
list($browse_table, $search_table, $browse_table_label, $empty_table, $tracking_icon) = PMA_getHtmlForActionLinks($current_table, $table_is_view, $tbl_url_query, $titles, $truename, $db_is_system_schema, $url_query);
//$browse_table
$this->assertContains($titles['NoBrowse'], $browse_table);
//$search_table
$this->assertContains($titles['NoSearch'], $search_table);
//$browse_table_label
$this->assertContains($tbl_url_query, $browse_table_label);
$this->assertContains($titles['NoEmpty'], $empty_table);
}
示例10: __construct
/**
* Initialises the class
*
* @param string $name An identifier for the new node
* @param int $type Type of node, may be one of CONTAINER or OBJECT
* @param bool $is_group Whether this object has been created
* while grouping nodes
*
* @return Node_Function
*/
public function __construct($name, $type = Node::OBJECT, $is_group = false)
{
parent::__construct($name, $type, $is_group);
$this->icon = PMA_Util::getImage('b_routines.png', __('Function'));
$this->links = array('text' => 'db_routines.php?server=' . $GLOBALS['server'] . '&db=%2$s&item_name=%1$s&item_type=FUNCTION' . '&edit_item=1&token=' . $_SESSION[' PMA_token '], 'icon' => 'db_routines.php?server=' . $GLOBALS['server'] . '&db=%2$s&item_name=%1$s&item_type=FUNCTION' . '&export_item=1&token=' . $_SESSION[' PMA_token ']);
$this->classes = 'function';
}
示例11: PMA_validateSQL
/**
* This function utilizes the Mimer SQL Validator service
* to validate an SQL query
*
* <http://developer.mimer.com/validator/index.htm>
*
* @param string $sql SQL query to validate
*
* @return string Validator result string
*
* @global array The PMA configuration array
*/
function PMA_validateSQL($sql)
{
global $cfg;
$str = '';
if ($cfg['SQLValidator']['use']) {
if (isset($GLOBALS['sqlvalidator_error']) && $GLOBALS['sqlvalidator_error']) {
$str = sprintf(__('The SQL validator could not be initialized. Please check if you have installed the necessary PHP extensions as described in the %sdocumentation%s.'), '<a href="' . PMA_Util::getDocuLink('faq', 'faqsqlvalidator') . '" target="documentation">', '</a>');
} else {
// create new class instance
$srv = new PMA_SQLValidator();
// Checks for username settings
// The class defaults to anonymous with an empty password
// automatically
if ($cfg['SQLValidator']['username'] != '') {
$srv->setCredentials($cfg['SQLValidator']['username'], $cfg['SQLValidator']['password']);
}
// Identify ourselves to the server properly...
$srv->appendCallingProgram('phpMyAdmin', PMA_VERSION);
// ... and specify what database system we are using
$srv->setTargetDbms('MySQL', PMA_MYSQL_STR_VERSION);
// Log on to service
$srv->start();
// Do service validation
$str = $srv->validationString($sql);
}
}
// end if
// Gives string back to caller
return $str;
}
示例12: __construct
/**
* Initialises the class
*
* @param string $name An identifier for the new node
* @param int $type Type of node, may be one of CONTAINER or OBJECT
* @param bool $is_group Whether this object has been created
* while grouping nodes
*
* @return Node_Procedure
*/
public function __construct($name, $type = Node::OBJECT, $is_group = false)
{
parent::__construct($name, $type, $is_group);
$this->icon = PMA_Util::getImage('b_routines.png', __('Procedure'));
$this->links = array('text' => 'db_routines.php?server=' . $GLOBALS['server'] . '&db=%2$s&item_name=%1$s&item_type=PROCEDURE' . '&execute_dialog=1&token=' . $GLOBALS['token'], 'icon' => 'db_routines.php?server=' . $GLOBALS['server'] . '&db=%2$s&item_name=%1$s&item_type=PROCEDURE' . '&edit_item=1&token=' . $GLOBALS['token']);
$this->classes = 'procedure';
}
示例13: test_generateHiddenMaxFileSize
/**
* @dataProvider dataProvider
* @return void
*/
function test_generateHiddenMaxFileSize($size)
{
$this->assertEquals(
PMA_Util::generateHiddenMaxFileSize($size),
'<input type="hidden" name="MAX_FILE_SIZE" value="' . $size . '" />'
);
}
示例14: __construct
/**
* Initialises the class
*
* @param string $name An identifier for the new node
* @param int $type Type of node, may be one of CONTAINER or OBJECT
* @param bool $is_group Whether this object has been created
* while grouping nodes
*
* @return Node_Index
*/
public function __construct($name, $type = Node::OBJECT, $is_group = false)
{
parent::__construct($name, $type, $is_group);
$this->icon = PMA_Util::getImage('b_index.png', __('Index'));
$this->links = array('text' => 'tbl_indexes.php?server=' . $GLOBALS['server'] . '&db=%3$s&table=%2$s&index=%1$s' . '&token=' . $_SESSION[' PMA_token '], 'icon' => 'tbl_indexes.php?server=' . $GLOBALS['server'] . '&db=%3$s&table=%2$s&index=%1$s' . '&token=' . $_SESSION[' PMA_token ']);
$this->classes = 'index';
}
示例15: PMA_RTE_handleExport
/**
* This function is called from one of the other functions in this file
* and it completes the handling of the export functionality.
*
* @param string $item_name The name of the item that we are exporting
* @param string $export_data The SQL query to create the requested item
*
* @return void
*/
function PMA_RTE_handleExport($item_name, $export_data)
{
global $db;
$item_name = htmlspecialchars(PMA_Util::backquote($_GET['item_name']));
if ($export_data !== false) {
$export_data = '<textarea cols="40" rows="15" style="width: 100%;">' . htmlspecialchars(trim($export_data)) . '</textarea>';
$title = sprintf(PMA_RTE_getWord('export'), $item_name);
if ($GLOBALS['is_ajax_request'] == true) {
$response = PMA_Response::getInstance();
$response->addJSON('message', $export_data);
$response->addJSON('title', $title);
exit;
} else {
echo "<fieldset>\n" . "<legend>{$title}</legend>\n" . $export_data . "</fieldset>\n";
}
} else {
$_db = htmlspecialchars(PMA_Util::backquote($db));
$message = __('Error in processing request:') . ' ' . sprintf(PMA_RTE_getWord('not_found'), $item_name, $_db);
$response = PMA_message::error($message);
if ($GLOBALS['is_ajax_request'] == true) {
$response = PMA_Response::getInstance();
$response->isSuccess(false);
$response->addJSON('message', $message);
exit;
} else {
$response->display();
}
}
}