Exemplo n.º 1
0
        $title = __('Privileges');
        foreach ($_REQUEST['selected_usr'] as $export_user) {
            $export_username = substr($export_user, 0, strpos($export_user, '&'));
            $export_hostname = substr($export_user, strrpos($export_user, ';') + 1);
            $response .= '# '
                . sprintf(
                    __('Privileges for %s'),
                    '`' . htmlspecialchars($export_username) . '`@`' . htmlspecialchars($export_hostname) . '`'
                )
                . "\n\n";
            $response .= PMA_getGrants($export_username, $export_hostname) . "\n";
        }
    } else {
        // export privileges for a single user
        $title = __('User') . ' `' . htmlspecialchars($username) . '`@`' . htmlspecialchars($hostname) . '`';
        $response .= PMA_getGrants($username, $hostname);
    }
    // remove trailing whitespace
    $response = trim($response);

    $response .= '</textarea>';
    unset($username, $hostname, $grants, $one_grant);
    if ($GLOBALS['is_ajax_request']) {
        PMA_ajaxResponse($response, 1, array('title' => $title));
    } else {
        echo "<h2>$title</h2>$response";
    }
}

if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs))) {
    if (! isset($username)) {
/**
 * Get title and textarea for export user definition in Privileges
 *
 * @param string $username username
 * @param string $hostname host name
 *
 * @return array ($title, $export)
 */
function PMA_getListForExportUserDefinition($username, $hostname)
{
    $export = '<textarea class="export" cols="60" rows="15">';
    if (isset($_REQUEST['selected_usr'])) {
        // export privileges for selected users
        $title = __('Privileges');
        foreach ($_REQUEST['selected_usr'] as $export_user) {
            $export_username = mb_substr($export_user, 0, mb_strpos($export_user, '&'));
            $export_hostname = mb_substr($export_user, mb_strrpos($export_user, ';') + 1);
            $export .= '# ' . sprintf(__('Privileges for %s'), '`' . htmlspecialchars($export_username) . '`@`' . htmlspecialchars($export_hostname) . '`') . "\n\n";
            $export .= PMA_getGrants($export_username, $export_hostname) . "\n";
        }
    } else {
        // export privileges for a single user
        $title = __('User') . ' `' . htmlspecialchars($username) . '`@`' . htmlspecialchars($hostname) . '`';
        $export .= PMA_getGrants($username, $hostname);
    }
    // remove trailing whitespace
    $export = trim($export);
    $export .= '</textarea>';
    return array($title, $export);
}
/**
 * Get title and textarea for export user definition in Privileges
 *
 * @param string $username username
 * @param string $hostname host name
 *
 * @return array ($title, $export)
 */
function PMA_getListForExportUserDefinition($username, $hostname)
{
    $export = '<textarea class="export" cols="' . $GLOBALS['cfg']['TextareaCols'] . '" rows="' . $GLOBALS['cfg']['TextareaRows'] . '">';
    if (isset($_REQUEST['selected_usr'])) {
        // export privileges for selected users
        $title = __('Privileges');
        /** @var PMA_String $pmaString */
        $pmaString = $GLOBALS['PMA_String'];
        foreach ($_REQUEST['selected_usr'] as $export_user) {
            $export_username = $pmaString->substr($export_user, 0, $pmaString->strpos($export_user, '&'));
            $export_hostname = $pmaString->substr($export_user, $pmaString->strrpos($export_user, ';') + 1);
            $export .= '# ' . sprintf(__('Privileges for %s'), '`' . htmlspecialchars($export_username) . '`@`' . htmlspecialchars($export_hostname) . '`') . "\n\n";
            $export .= PMA_getGrants($export_username, $export_hostname) . "\n";
        }
    } else {
        // export privileges for a single user
        $title = __('User') . ' `' . htmlspecialchars($username) . '`@`' . htmlspecialchars($hostname) . '`';
        $export .= PMA_getGrants($username, $hostname);
    }
    // remove trailing whitespace
    $export = trim($export);
    $export .= '</textarea>';
    return array($title, $export);
}