/**
     * Test for PMA_Bookmark_save
     *
     * @return void
     */
    public function testPMA_Bookmark_save()
    {
        $bookmark = array(
            'dbase' => 'phpmyadmin',
            'user' => 'phpmyadmin',
            'query' => 'SELECT "phpmyadmin"',
            'label' => 'phpmyadmin',
        );

        $this->assertfalse(PMA_Bookmark_save($bookmark));
    }
Example #2
0
/**
 * Function to store the query as a bookmark
 *
 * @param String  $db                     the current database
 * @param String  $bkm_user               the bookmarking user
 * @param String  $sql_query_for_bookmark the query to be stored in bookmark
 * @param String  $bkm_label              bookmark label
 * @param boolean $bkm_replace            whether to replace existing bookmarks
 *
 * @return void
 */
function PMA_storeTheQueryAsBookmark($db, $bkm_user, $sql_query_for_bookmark, $bkm_label, $bkm_replace)
{
    include_once 'libraries/bookmark.lib.php';
    $bfields = array('bkm_database' => $db, 'bkm_user' => $bkm_user, 'bkm_sql_query' => urlencode($sql_query_for_bookmark), 'bkm_label' => $bkm_label);
    // Should we replace bookmark?
    if (isset($bkm_replace)) {
        $bookmarks = PMA_Bookmark_getList($db);
        foreach ($bookmarks as $key => $val) {
            if ($val == $bkm_label) {
                PMA_Bookmark_delete($key);
            }
        }
    }
    PMA_Bookmark_save($bfields, isset($_POST['bkm_all_users']));
}
Example #3
0
    $go_sql = TRUE;
}
// Store the query as a bookmark before executing it if bookmarklabel was given
if (!empty($bkm_label) && !empty($import_text)) {
    require_once './libraries/bookmark.lib.php';
    $bfields = array('dbase' => $db, 'user' => $cfg['Bookmark']['user'], 'query' => urlencode($import_text), 'label' => $bkm_label);
    // Should we replace bookmark?
    if (isset($bkm_replace)) {
        $bookmarks = PMA_Bookmark_getList($db);
        foreach ($bookmarks as $key => $val) {
            if ($val == $bkm_label) {
                PMA_Bookmark_delete($db, $key);
            }
        }
    }
    PMA_Bookmark_save($bfields, isset($bkm_all_users));
    $bookmark_created = TRUE;
}
// end store bookmarks
// We can not read all at once, otherwise we can run out of memory
$memory_limit = trim(@ini_get('memory_limit'));
// 2 MB as default
if (empty($memory_limit)) {
    $memory_limit = 2 * 1024 * 1024;
}
// In case no memory limit we work on 10MB chunks
if ($memory_limit == -1) {
    $memory_limit = 10 * 1024 * 1024;
}
// Calculate value of the limit
if (strtolower(substr($memory_limit, -1)) == 'm') {
Example #4
0
PMA_displayTable_checkConfigParams();

/**
 * Need to find the real end of rows?
 */
if (isset($find_real_end) && $find_real_end) {
    $unlim_num_rows = PMA_Table::countRecords($db, $table, $force_exact = true);
    $_SESSION['tmp_user_values']['pos'] = @((ceil($unlim_num_rows / $_SESSION['tmp_user_values']['max_rows']) - 1) * $_SESSION['tmp_user_values']['max_rows']);
}


/**
 * Bookmark add
 */
if (isset($store_bkm)) {
    PMA_Bookmark_save($fields, (isset($bkm_all_users) && $bkm_all_users == 'true' ? true : false));
    // go back to sql.php to redisplay query; do not use & in this case:
    PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . $goto . '&label=' . $fields['label']);
} // end if

/**
 * Parse and analyze the query
 */
require_once 'libraries/parse_analyze.lib.php';

/**
 * Sets or modifies the $goto variable if required
 */
if ($goto == 'sql.php') {
    $is_gotofile = false;
    $goto = 'sql.php?'
Example #5
0
    exit;
}
// If it's a refresh console bookmarks request
if (isset($_REQUEST['console_bookmark_refresh'])) {
    $response = PMA_Response::getInstance();
    $response->addJSON('console_message_bookmark', PMA_Console::getBookmarkContent());
    exit;
}
// If it's a console bookmark add request
if (isset($_REQUEST['console_bookmark_add'])) {
    $response = PMA_Response::getInstance();
    if (isset($_REQUEST['label']) && isset($_REQUEST['db']) && isset($_REQUEST['bookmark_query']) && isset($_REQUEST['shared'])) {
        $cfgBookmark = PMA_Bookmark_getParams();
        $bookmarkFields = array('bkm_database' => $_REQUEST['db'], 'bkm_user' => $cfgBookmark['user'], 'bkm_sql_query' => urlencode($_REQUEST['bookmark_query']), 'bkm_label' => $_REQUEST['label']);
        $isShared = $_REQUEST['shared'] == 'true' ? true : false;
        if (PMA_Bookmark_save($bookmarkFields, $isShared)) {
            $response->addJSON('message', __('Succeeded'));
            $response->addJSON('data', $bookmarkFields);
            $response->addJSON('isShared', $isShared);
        } else {
            $response->addJSON('message', __('Failed'));
        }
        die;
    } else {
        $response->addJSON('message', __('Incomplete params'));
        die;
    }
}
/**
 * Sets globals from $_POST
 */
 /**
  * Test for PMA_Bookmark_save
  */
 public function testPMA_Bookmark_save(){
     if (! function_exists('PMA_DBI_query')) {
         function PMA_DBI_query()
         {
             return false;
         }
     }
     $this->assertfalse(
         PMA_Bookmark_save(array(
             'dbase' => 'phpmyadmin',
             'user' => 'phpmyadmin',
             'query' => 'SELECT "phpmyadmin"',
             'label' => 'phpmyadmin',
         ))
     );
 }