/**
  * getMessage test - with empty message and with non-empty string -
  * not key in globals additional params are defined
  *
  * @return void
  */
 public function testGetMessageWithoutMessageWithStringWithParams()
 {
     $this->object->setMessage('');
     $this->object->setString('test string %s %s');
     $this->object->addParam('test param 1');
     $this->object->addParam('test param 2');
     $this->assertEquals('test string test param 1 test param 2', $this->object->getMessage());
 }
/**
 * Get HTML snippet for display user overview page
 *
 * @param string $pmaThemeImage a image source link
 * @param string $text_dir      text directory
 *
 * @return string $html_output
 */
function PMA_getHtmlForUserOverview($pmaThemeImage, $text_dir)
{
    $html_output = '<h2>' . "\n" . PMA_Util::getIcon('b_usrlist.png') . __('Users overview') . "\n" . '</h2>' . "\n";
    $password_column = 'Password';
    if (PMA_Util::getServerType() == 'MySQL' && PMA_MYSQL_INT_VERSION >= 50706) {
        $password_column = 'authentication_string';
    }
    // $sql_query is for the initial-filtered,
    // $sql_query_all is for counting the total no. of users
    $sql_query = $sql_query_all = 'SELECT *,' . " IF(`" . $password_column . "` = _latin1 '', 'N', 'Y') AS 'Password'" . ' FROM `mysql`.`user`';
    $sql_query .= isset($_REQUEST['initial']) ? PMA_rangeOfUsers($_REQUEST['initial']) : '';
    $sql_query .= ' ORDER BY `User` ASC, `Host` ASC;';
    $sql_query_all .= ' ;';
    $res = $GLOBALS['dbi']->tryQuery($sql_query, null, PMA_DatabaseInterface::QUERY_STORE);
    $res_all = $GLOBALS['dbi']->tryQuery($sql_query_all, null, PMA_DatabaseInterface::QUERY_STORE);
    if (!$res) {
        // the query failed! This may have two reasons:
        // - the user does not have enough privileges
        // - the privilege tables use a structure of an earlier version.
        // so let's try a more simple query
        $GLOBALS['dbi']->freeResult($res);
        $GLOBALS['dbi']->freeResult($res_all);
        $sql_query = 'SELECT * FROM `mysql`.`user`';
        $res = $GLOBALS['dbi']->tryQuery($sql_query, null, PMA_DatabaseInterface::QUERY_STORE);
        if (!$res) {
            $html_output .= PMA_getHtmlForViewUsersError();
            $html_output .= PMA_getAddUserHtmlFieldset();
        } else {
            // This message is hardcoded because I will replace it by
            // a automatic repair feature soon.
            $raw = 'Your privilege table structure seems to be older than' . ' this MySQL version!<br />' . 'Please run the <code>mysql_upgrade</code> command' . '(<code>mysql_fix_privilege_tables</code> on older systems)' . ' that should be included in your MySQL server distribution' . ' to solve this problem!';
            $html_output .= PMA_Message::rawError($raw)->getDisplay();
        }
        $GLOBALS['dbi']->freeResult($res);
    } else {
        $db_rights = PMA_getDbRightsForUserOverview();
        // for all initials, even non A-Z
        $array_initials = array();
        /**
         * Displays the initials
         * Also not necessary if there is less than 20 privileges
         */
        if ($GLOBALS['dbi']->numRows($res_all) > 20) {
            $html_output .= PMA_getHtmlForInitials($array_initials);
        }
        /**
         * Display the user overview
         * (if less than 50 users, display them immediately)
         */
        if (isset($_REQUEST['initial']) || isset($_REQUEST['showall']) || $GLOBALS['dbi']->numRows($res) < 50) {
            $html_output .= PMA_getUsersOverview($res, $db_rights, $pmaThemeImage, $text_dir);
        } else {
            $html_output .= PMA_getAddUserHtmlFieldset();
        }
        // end if (display overview)
        if (!$GLOBALS['is_ajax_request'] || !empty($_REQUEST['ajax_page_request'])) {
            $flushnote = new PMA_Message(__('Note: phpMyAdmin gets the users\' privileges directly ' . 'from MySQL\'s privilege tables. The content of these tables ' . 'may differ from the privileges the server uses, ' . 'if they have been changed manually. In this case, ' . 'you should %sreload the privileges%s before you continue.'), PMA_Message::NOTICE);
            $flushLink = '<a href="server_privileges.php' . PMA_URL_getCommon(array('flush_privileges' => 1)) . '" id="reload_privileges_anchor">';
            $flushnote->addParam($flushLink, false);
            $flushnote->addParam('</a>', false);
            $html_output .= $flushnote->getDisplay();
        }
    }
    return $html_output;
}
            } else {

                unset ($row);
                echo '    <fieldset id="fieldset_add_user">' . "\n"
                   . '        <a href="server_privileges.php?' . $GLOBALS['url_query'] . '&amp;adduser=1" class="' . $conditional_class . '">' . "\n"
                   . PMA_getIcon('b_usradd.png')
                   . '            ' . __('Add user') . '</a>' . "\n"
                   . '    </fieldset>' . "\n";
            } // end if (display overview)

            if ($GLOBALS['is_ajax_request']) {
                exit;
            }

            $flushnote = new PMA_Message(__('Note: phpMyAdmin gets the users\' privileges directly from MySQL\'s privilege tables. The content of these tables may differ from the privileges the server uses, if they have been changed manually. In this case, you should %sreload the privileges%s before you continue.'), PMA_Message::NOTICE);
            $flushnote->addParam('<a href="server_privileges.php?' . $GLOBALS['url_query'] . '&amp;flush_privileges=1" id="reload_privileges_anchor" class="' . $conditional_class . '">', false);
            $flushnote->addParam('</a>', false);
            $flushnote->display();
        }


    } else {

        // A user was selected -> display the user's properties

        // In an Ajax request, prevent cached values from showing
        if ($GLOBALS['is_ajax_request'] == true) {
            header('Cache-Control: no-cache');
        }

        echo '<h2>' . "\n"
    <label for="filename_template">
        <?php 
echo $strFileNameTemplate;
$trans = new PMA_Message();
$trans->addMessage('__SERVER__/');
$trans->addString('strFileNameTemplateDescriptionServer');
if ($export_type == 'database' || $export_type == 'table') {
    $trans->addMessage('__DB__/');
    $trans->addString('strFileNameTemplateDescriptionDatabase');
    if ($export_type == 'table') {
        $trans->addMessage('__TABLE__/');
        $trans->addString('strFileNameTemplateDescriptionTable');
    }
}
$message = new PMA_Message('strFileNameTemplateDescription');
$message->addParam('<a href="http://php.net/strftime" target="documentation" title="' . $strDocu . '">', false);
$message->addParam('</a>', false);
$message->addParam($trans);
echo PMA_showHint($message);
?>
        </label>:
    <input type="text" name="filename_template" id="filename_template"
    <?php 
echo ' value="';
if ($export_type == 'database') {
    if (isset($_COOKIE) && !empty($_COOKIE['pma_db_filename_template'])) {
        echo htmlspecialchars($_COOKIE['pma_db_filename_template']);
    } else {
        echo $GLOBALS['cfg']['Export']['file_template_database'];
    }
} elseif ($export_type == 'table') {
/**
 * Prints Html For Export Options
 *
 * @param String $export_type Selected Export Type
 *
 * @return string
 */
function PMA_getHtmlForExportOptionsOutputFormat($export_type)
{
    $html = '<li>';
    $html .= '<label for="filename_template" class="desc">';
    $html .= __('File name template:');
    $trans = new PMA_Message();
    $trans->addMessage(__('@SERVER@ will become the server name'));
    if ($export_type == 'database' || $export_type == 'table') {
        $trans->addMessage(__(', @DATABASE@ will become the database name'));
        if ($export_type == 'table') {
            $trans->addMessage(__(', @TABLE@ will become the table name'));
        }
    }
    $msg = new PMA_Message(__('This value is interpreted using %1$sstrftime%2$s, ' . 'so you can use time formatting strings. ' . 'Additionally the following transformations will happen: %3$s. ' . 'Other text will be kept as is. See the %4$sFAQ%5$s for details.'));
    $msg->addParam('<a href="' . PMA_linkURL(PMA_getPHPDocLink('function.strftime.php')) . '" target="documentation" title="' . __('Documentation') . '">', false);
    $msg->addParam('</a>', false);
    $msg->addParam($trans);
    $doc_url = PMA_Util::getDocuLink('faq', 'faq6-27');
    $msg->addParam('<a href="' . $doc_url . '" target="documentation">', false);
    $msg->addParam('</a>', false);
    $html .= PMA_Util::showHint($msg);
    $html .= '</label>';
    $html .= '<input type="text" name="filename_template" id="filename_template" ';
    $html .= ' value="';
    if (isset($_GET['filename_template'])) {
        $html .= htmlspecialchars($_GET['filename_template']);
    } else {
        if ($export_type == 'database') {
            $html .= htmlspecialchars($GLOBALS['PMA_Config']->getUserValue('pma_db_filename_template', $GLOBALS['cfg']['Export']['file_template_database']));
        } elseif ($export_type == 'table') {
            $html .= htmlspecialchars($GLOBALS['PMA_Config']->getUserValue('pma_table_filename_template', $GLOBALS['cfg']['Export']['file_template_table']));
        } else {
            $html .= htmlspecialchars($GLOBALS['PMA_Config']->getUserValue('pma_server_filename_template', $GLOBALS['cfg']['Export']['file_template_server']));
        }
    }
    $html .= '"';
    $html .= '/>';
    $html .= '<input type="checkbox" name="remember_template" ';
    $html .= 'id="checkbox_remember_template" ';
    $html .= PMA_exportCheckboxCheck('remember_file_template');
    $html .= '/>';
    $html .= '<label for="checkbox_remember_template">';
    $html .= __('use this for future exports');
    $html .= '</label>';
    $html .= '</li>';
    return $html;
}
/**
 * Get HTML snippet for display user overview page
 *
 * @param string $link_edit         standard link to edit privileges
 * @param string $pmaThemeImage     a image source link
 * @param string $text_dir          text directory
 * @param string $conditional_class if ajaxable 'Ajax' otherwise ''
 * @param string $link_export       standard link to export privileges
 *
 * @return string $html_output
 */
function PMA_getHtmlForDisplayUserOverviewPage($link_edit, $pmaThemeImage, $text_dir, $conditional_class, $link_export)
{
    $html_output = '<h2>' . "\n" . PMA_Util::getIcon('b_usrlist.png') . __('Users overview') . "\n" . '</h2>' . "\n";
    $sql_query = 'SELECT *,' . "       IF(`Password` = _latin1 '', 'N', 'Y') AS 'Password'" . '  FROM `mysql`.`user`';
    $sql_query .= isset($_REQUEST['initial']) ? PMA_rangeOfUsers($_REQUEST['initial']) : '';
    $sql_query .= ' ORDER BY `User` ASC, `Host` ASC;';
    $res = PMA_DBI_try_query($sql_query, null, PMA_DBI_QUERY_STORE);
    if (!$res) {
        // the query failed! This may have two reasons:
        // - the user does not have enough privileges
        // - the privilege tables use a structure of an earlier version.
        // so let's try a more simple query
        $sql_query = 'SELECT * FROM `mysql`.`user`';
        $res = PMA_DBI_try_query($sql_query, null, PMA_DBI_QUERY_STORE);
        if (!$res) {
            $html_output .= PMA_Message::error(__('No Privileges'))->getDisplay();
            PMA_DBI_free_result($res);
            unset($res);
        } else {
            // This message is hardcoded because I will replace it by
            // a automatic repair feature soon.
            $raw = 'Your privilege table structure seems to be older than' . ' this MySQL version!<br />' . 'Please run the <code>mysql_upgrade</code> command' . '(<code>mysql_fix_privilege_tables</code> on older systems)' . ' that should be included in your MySQL server distribution' . ' to solve this problem!';
            $html_output .= PMA_Message::rawError($raw)->getDisplay();
        }
    } else {
        $db_rights = PMA_getDbRightsForUserOverview();
        // for all initials, even non A-Z
        $array_initials = array();
        /**
         * Displays the initials
         * Also not necassary if there is less than 20 privileges
         */
        if (PMA_DBI_num_rows($res) > 20) {
            $html_output .= PMA_getHtmlForDisplayTheInitials($array_initials, $conditional_class);
        }
        /**
         * Display the user overview
         * (if less than 50 users, display them immediately)
         */
        if (isset($_REQUEST['initial']) || isset($_REQUEST['showall']) || PMA_DBI_num_rows($res) < 50) {
            $html_output .= PMA_getUsersOverview($res, $db_rights, $link_edit, $pmaThemeImage, $text_dir, $conditional_class, $link_export);
        } else {
            $html_output .= PMA_getAddUserHtmlFieldset($conditional_class);
        }
        // end if (display overview)
        if (!$GLOBALS['is_ajax_request'] || !empty($_REQUEST['ajax_page_request'])) {
            $flushnote = new PMA_Message(__('Note: phpMyAdmin gets the users\' privileges directly from MySQL\'s privilege tables. The content of these tables may differ from the privileges the server uses, if they have been changed manually. In this case, you should %sreload the privileges%s before you continue.'), PMA_Message::NOTICE);
            $flushLink = '<a href="server_privileges.php?' . $GLOBALS['url_query'] . '&amp;' . 'flush_privileges=1" id="reload_privileges_anchor" ' . 'class="' . $conditional_class . '">';
            $flushnote->addParam($flushLink, false);
            $flushnote->addParam('</a>', false);
            $html_output .= $flushnote->getDisplay();
        }
        return $html_output;
    }
}
}
?>
                <li>
                    <label for="filename_template" class="desc">
                    <?php 
echo __('File name template:');
$trans = new PMA_Message();
$trans->addMessage(__('@SERVER@ will become the server name'));
if ($export_type == 'database' || $export_type == 'table') {
    $trans->addMessage(__(', @DATABASE@ will become the database name'));
    if ($export_type == 'table') {
        $trans->addMessage(__(', @TABLE@ will become the table name'));
    }
}
$message = new PMA_Message(__('This value is interpreted using %1$sstrftime%2$s, so you can use time formatting strings. Additionally the following transformations will happen: %3$s. Other text will be kept as is. See the %4$sFAQ%5$s for details.'));
$message->addParam('<a href="' . PMA_linkURL(PMA_getPHPDocLink('function.strftime.php')) . '" target="documentation" title="' . __('Documentation') . '">', false);
$message->addParam('</a>', false);
$message->addParam($trans);
$message->addParam('<a href="Documentation.html#faq6_27" target="documentation">', false);
$message->addParam('</a>', false);
echo PMA_showHint($message);
?>
                    </label>
                    <input type="text" name="filename_template" id="filename_template"
                    <?php 
echo ' value="';
if (isset($_GET['filename_template'])) {
    echo htmlspecialchars($_GET['filename_template']);
} else {
    if ($export_type == 'database') {
        echo htmlspecialchars($GLOBALS['PMA_Config']->getUserValue('pma_db_filename_template', $GLOBALS['cfg']['Export']['file_template_database']));
示例#8
0
                     printf($link_edit, urlencode($host['User']), urlencode($host['Host']), '', '');
                     echo '</td>' . "\n" . '        </tr>' . "\n";
                     $odd_row = !$odd_row;
                 }
             }
             unset($user, $host, $odd_row);
             echo '    </tbody></table>' . "\n" . '<img class="selectallarrow"' . ' src="' . $pmaThemeImage . 'arrow_' . $text_dir . '.png"' . ' width="38" height="22"' . ' alt="' . $GLOBALS['strWithChecked'] . '" />' . "\n" . '<a href="server_privileges.php?' . $GLOBALS['url_query'] . '&amp;checkall=1"' . ' onclick="if (markAllRows(\'usersForm\')) return false;">' . $GLOBALS['strCheckAll'] . '</a>' . "\n" . '/' . "\n" . '<a href="server_privileges.php?' . $GLOBALS['url_query'] . '"' . ' onclick="if (unMarkAllRows(\'usersForm\')) return false;">' . $GLOBALS['strUncheckAll'] . '</a>' . "\n";
             // add/delete user fieldset
             echo '    <fieldset id="fieldset_add_user">' . "\n" . '        <a href="server_privileges.php?' . $GLOBALS['url_query'] . '&amp;adduser=1">' . "\n" . PMA_getIcon('b_usradd.png') . '            ' . $GLOBALS['strAddUser'] . '</a>' . "\n" . '    </fieldset>' . "\n" . '    <fieldset id="fieldset_delete_user">' . '        <legend>' . "\n" . PMA_getIcon('b_usrdrop.png') . '            ' . $GLOBALS['strRemoveSelectedUsers'] . '' . "\n" . '        </legend>' . "\n" . '        <input type="hidden" name="mode" value="2" />' . "\n" . '(' . $GLOBALS['strRevokeAndDelete'] . ')<br />' . "\n" . '        <input type="checkbox" title="' . $GLOBALS['strDropUsersDb'] . '" name="drop_users_db" id="checkbox_drop_users_db" />' . "\n" . '        <label for="checkbox_drop_users_db" title="' . $GLOBALS['strDropUsersDb'] . '">' . "\n" . '            ' . $GLOBALS['strDropUsersDb'] . "\n" . '        </label>' . "\n" . '    </fieldset>' . "\n" . '    <fieldset id="fieldset_delete_user_footer" class="tblFooters">' . "\n" . '        <input type="submit" name="delete" value="' . $GLOBALS['strGo'] . '" id="buttonGo" />' . "\n" . '    </fieldset>' . "\n" . '</form>' . "\n";
         } else {
             unset($row);
             echo '    <fieldset id="fieldset_add_user">' . "\n" . '        <a href="server_privileges.php?' . $GLOBALS['url_query'] . '&amp;adduser=1">' . "\n" . PMA_getIcon('b_usradd.png') . '            ' . $GLOBALS['strAddUser'] . '</a>' . "\n" . '    </fieldset>' . "\n";
         }
         // end if (display overview)
         $flushnote = new PMA_Message('strFlushPrivilegesNote', PMA_Message::NOTICE);
         $flushnote->addParam('<a href="server_privileges.php?' . $GLOBALS['url_query'] . '&amp;flush_privileges=1">', false);
         $flushnote->addParam('</a>', false);
         $flushnote->display();
     }
 } else {
     // A user was selected -> display the user's properties
     echo '<h2>' . "\n" . PMA_getIcon('b_usredit.png') . $GLOBALS['strEditPrivileges'] . ': ' . $GLOBALS['strUser'];
     if (isset($dbname)) {
         echo ' <i><a href="server_privileges.php?' . $GLOBALS['url_query'] . '&amp;username='******'&amp;hostname=' . htmlspecialchars(urlencode($hostname)) . '&amp;dbname=&amp;tablename=">\'' . htmlspecialchars($username) . '\'@\'' . htmlspecialchars($hostname) . '\'</a></i>' . "\n";
         $url_dbname = urlencode(str_replace(array('\\_', '\\%'), array('_', '%'), $dbname));
         echo ' - ' . ($dbname_is_wildcard ? $GLOBALS['strDatabases'] : $GLOBALS['strDatabase']);
         if (isset($tablename)) {
             echo ' <i><a href="server_privileges.php?' . $GLOBALS['url_query'] . '&amp;username='******'&amp;hostname=' . htmlspecialchars(urlencode($hostname)) . '&amp;dbname=' . htmlspecialchars($url_dbname) . '&amp;tablename=">' . htmlspecialchars($dbname) . '</a></i>';
             echo ' - ' . $GLOBALS['strTable'] . ' <i>' . htmlspecialchars($tablename) . '</i>';
         } else {
             echo ' <i>' . htmlspecialchars($dbname) . '</i>';
示例#9
0
    echo '</label>';
    echo '</li>';
}
echo '<li>';
echo '<label for="filename_template" class="desc">';
echo __('File name template:');
$trans = new PMA_Message();
$trans->addMessage(__('@SERVER@ will become the server name'));
if ($export_type == 'database' || $export_type == 'table') {
    $trans->addMessage(__(', @DATABASE@ will become the database name'));
    if ($export_type == 'table') {
        $trans->addMessage(__(', @TABLE@ will become the table name'));
    }
}
$msg = new PMA_Message(__('This value is interpreted using %1$sstrftime%2$s, so you can use time formatting strings. Additionally the following transformations will happen: %3$s. Other text will be kept as is. See the %4$sFAQ%5$s for details.'));
$msg->addParam('<a href="' . PMA_linkURL(PMA_getPHPDocLink('function.strftime.php')) . '" target="documentation" title="' . __('Documentation') . '">', false);
$msg->addParam('</a>', false);
$msg->addParam($trans);
$doc_url = PMA_Util::getDocuLink('faq', 'faq6-27');
$msg->addParam('<a href="' . $doc_url . '" target="documentation">', false);
$msg->addParam('</a>', false);
echo PMA_Util::showHint($msg);
echo '</label>';
echo '<input type="text" name="filename_template" id="filename_template" ';
echo ' value="';
if (isset($_GET['filename_template'])) {
    echo htmlspecialchars($_GET['filename_template']);
} else {
    if ($export_type == 'database') {
        echo htmlspecialchars($GLOBALS['PMA_Config']->getUserValue('pma_db_filename_template', $GLOBALS['cfg']['Export']['file_template_database']));
    } elseif ($export_type == 'table') {