예제 #1
0
 /**
  * Sends a JSON response to the browser
  *
  * @return void
  */
 private function _ajaxResponse()
 {
     /* Avoid wrapping in case we're disabled */
     if ($this->_isDisabled) {
         echo $this->_getDisplay();
         return;
     }
     if (!isset($this->_JSON['message'])) {
         $this->_JSON['message'] = $this->_getDisplay();
     } else {
         if ($this->_JSON['message'] instanceof Message) {
             $this->_JSON['message'] = $this->_JSON['message']->getDisplay();
         }
     }
     if ($this->_isSuccess) {
         $this->_JSON['success'] = true;
     } else {
         $this->_JSON['success'] = false;
         $this->_JSON['error'] = $this->_JSON['message'];
         unset($this->_JSON['message']);
     }
     if ($this->_isSuccess) {
         // Note: the old judge sentence is:
         // $this->_isAjaxPage && $this->_isSuccess
         // Removal the first, because console need log all queries
         $this->addJSON('_title', $this->getHeader()->getTitleTag());
         if (isset($GLOBALS['dbi'])) {
             $menuHash = $this->getHeader()->getMenu()->getHash();
             $this->addJSON('_menuHash', $menuHash);
             $hashes = array();
             if (isset($_REQUEST['menuHashes'])) {
                 $hashes = explode('-', $_REQUEST['menuHashes']);
             }
             if (!in_array($menuHash, $hashes)) {
                 $this->addJSON('_menu', $this->getHeader()->getMenu()->getDisplay());
             }
         }
         $this->addJSON('_scripts', $this->getHeader()->getScripts()->getFiles());
         $this->addJSON('_selflink', $this->getFooter()->getSelfUrl('unencoded'));
         $this->addJSON('_displayMessage', $this->getHeader()->getMessage());
         $debug = $this->_footer->getDebugMessage();
         if (empty($_REQUEST['no_debug']) && mb_strlen($debug)) {
             $this->addJSON('_debug', $debug);
         }
         $errors = $this->_footer->getErrorMessages();
         if (mb_strlen($errors)) {
             $this->addJSON('_errors', $errors);
         }
         $promptPhpErrors = $GLOBALS['error_handler']->hasErrorsForPrompt();
         $this->addJSON('_promptPhpErrors', $promptPhpErrors);
         if (empty($GLOBALS['error_message'])) {
             // set current db, table and sql query in the querywindow
             // (this is for the bottom console)
             $query = '';
             $maxChars = $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'];
             if (isset($GLOBALS['sql_query']) && mb_strlen($GLOBALS['sql_query']) < $maxChars) {
                 $query = $GLOBALS['sql_query'];
             }
             $this->addJSON('_reloadQuerywindow', array('db' => PMA_ifSetOr($GLOBALS['db'], ''), 'table' => PMA_ifSetOr($GLOBALS['table'], ''), 'sql_query' => $query));
             if (!empty($GLOBALS['focus_querywindow'])) {
                 $this->addJSON('_focusQuerywindow', $query);
             }
             if (!empty($GLOBALS['reload'])) {
                 $this->addJSON('_reloadNavigation', 1);
             }
             $this->addJSON('_params', $this->getHeader()->getJsParams());
         }
     }
     // Set the Content-Type header to JSON so that jQuery parses the
     // response correctly.
     PMA_headerJSON();
     $result = json_encode($this->_JSON);
     if ($result === false) {
         switch (json_last_error()) {
             case JSON_ERROR_NONE:
                 $error = 'No errors';
                 break;
             case JSON_ERROR_DEPTH:
                 $error = 'Maximum stack depth exceeded';
                 break;
             case JSON_ERROR_STATE_MISMATCH:
                 $error = 'Underflow or the modes mismatch';
                 break;
             case JSON_ERROR_CTRL_CHAR:
                 $error = 'Unexpected control character found';
                 break;
             case JSON_ERROR_SYNTAX:
                 $error = 'Syntax error, malformed JSON';
                 break;
             case JSON_ERROR_UTF8:
                 $error = 'Malformed UTF-8 characters, possibly incorrectly encoded';
                 break;
             case JSON_ERROR_RECURSION:
                 $error = 'One or more recursive references in the value to be encoded';
                 break;
             case JSON_ERROR_INF_OR_NAN:
                 $error = 'One or more NAN or INF values in the value to be encoded';
                 break;
             case JSON_ERROR_UNSUPPORTED_TYPE:
                 $error = 'A value of a type that cannot be encoded was given';
             default:
                 $error = 'Unknown error';
                 break;
         }
         echo json_encode(array('success' => false, 'error' => 'JSON encoding failed: ' . $error));
     } else {
         echo $result;
     }
 }
예제 #2
0
 /**
  * Sends a JSON response to the browser
  *
  * @return void
  */
 private function _ajaxResponse()
 {
     if (!isset($this->_JSON['message'])) {
         $this->_JSON['message'] = $this->_getDisplay();
     } else {
         if ($this->_JSON['message'] instanceof PMA_Message) {
             $this->_JSON['message'] = $this->_JSON['message']->getDisplay();
         }
     }
     if ($this->_isSuccess) {
         $this->_JSON['success'] = true;
     } else {
         $this->_JSON['success'] = false;
         $this->_JSON['error'] = $this->_JSON['message'];
         unset($this->_JSON['message']);
     }
     if ($this->_isSuccess) {
         // Note: the old judge sentence is:
         // $this->_isAjaxPage && $this->_isSuccess
         // Removal the first, because console need log all queries, if caused any
         // bug, contact Edward Cheng
         $this->addJSON('_title', $this->getHeader()->getTitleTag());
         if (isset($GLOBALS['dbi'])) {
             $menuHash = $this->getHeader()->getMenu()->getHash();
             $this->addJSON('_menuHash', $menuHash);
             $hashes = array();
             if (isset($_REQUEST['menuHashes'])) {
                 $hashes = explode('-', $_REQUEST['menuHashes']);
             }
             if (!in_array($menuHash, $hashes)) {
                 $this->addJSON('_menu', $this->getHeader()->getMenu()->getDisplay());
             }
         }
         $this->addJSON('_scripts', $this->getHeader()->getScripts()->getFiles());
         $this->addJSON('_selflink', $this->getFooter()->getSelfUrl('unencoded'));
         $this->addJSON('_displayMessage', $this->getHeader()->getMessage());
         $debug = $this->_footer->getDebugMessage();
         if (empty($_REQUEST['no_debug']) && mb_strlen($debug)) {
             $this->addJSON('_debug', $debug);
         }
         $errors = $this->_footer->getErrorMessages();
         if (mb_strlen($errors)) {
             $this->addJSON('_errors', $errors);
         }
         $promptPhpErrors = $GLOBALS['error_handler']->hasErrorsForPrompt();
         $this->addJSON('_promptPhpErrors', $promptPhpErrors);
         if (empty($GLOBALS['error_message'])) {
             // set current db, table and sql query in the querywindow
             // (this is for the bottom console)
             $query = '';
             $maxChars = $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'];
             if (isset($GLOBALS['sql_query']) && mb_strlen($GLOBALS['sql_query']) < $maxChars) {
                 $query = $GLOBALS['sql_query'];
             }
             $this->addJSON('_reloadQuerywindow', array('db' => PMA_ifSetOr($GLOBALS['db'], ''), 'table' => PMA_ifSetOr($GLOBALS['table'], ''), 'sql_query' => $query));
             if (!empty($GLOBALS['focus_querywindow'])) {
                 $this->addJSON('_focusQuerywindow', $query);
             }
             if (!empty($GLOBALS['reload'])) {
                 $this->addJSON('_reloadNavigation', 1);
             }
             $this->addJSON('_params', $this->getHeader()->getJsParams());
         }
     }
     // Set the Content-Type header to JSON so that jQuery parses the
     // response correctly.
     PMA_headerJSON();
     echo json_encode($this->_JSON);
 }
예제 #3
0
    $html = PMA_findPartialDependencies($table, $db);
    echo $html;
    exit;
}
if (isset($_REQUEST['getNewTables2NF'])) {
    $partialDependencies = json_decode($_REQUEST['pd']);
    $html = PMA_getHtmlForNewTables2NF($partialDependencies, $table);
    echo $html;
    exit;
}
if (isset($_REQUEST['getNewTables3NF'])) {
    $dependencies = json_decode($_REQUEST['pd']);
    $tables = json_decode($_REQUEST['tables']);
    $newTables = PMA_getHtmlForNewTables3NF($dependencies, $tables, $db);
    PMA_Response::getInstance()->disable();
    PMA_headerJSON();
    echo json_encode($newTables);
    exit;
}
$response = PMA_Response::getInstance();
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('normalization.js');
$scripts->addFile('jquery/jquery.uitablefilter.js');
$normalForm = '1nf';
if (isset($_REQUEST['normalizeTo'])) {
    $normalForm = $_REQUEST['normalizeTo'];
}
if (isset($_REQUEST['createNewTables2NF'])) {
    $partialDependencies = json_decode($_REQUEST['pd']);
    $tablesName = json_decode($_REQUEST['newTablesName']);
예제 #4
0
/**
 * The function outputs json encoded status of uploaded.
 * It uses PMA_getUploadStatus, which is defined in plugin's file.
 *
 * @param string $id ID of transfer, usually $upload_id
 *                   from display_import_ajax.lib.php
 *
 * @return void
 */
function PMA_importAjaxStatus($id)
{
    PMA_headerJSON();
    echo json_encode($_SESSION[$GLOBALS['SESSION_KEY']]['handler']::getUploadStatus($id));
}