PMA\libraries\Util::checkParameters PHP Method

checkParameters() public static method

Called by each script that needs parameters, it displays an error message and, by default, stops the execution. Not sure we could use a strMissingParameter message here, would have to check if the error message file is always available
public static checkParameters ( string[] $params, boolean $request = true ) : void
$params string[] The names of the parameters needed by the calling script
$request boolean Whether to include this list in checking for special params
return void
    public static function checkParameters($params, $request = true)
    {
        global $checked_special;
        if (!isset($checked_special)) {
            $checked_special = false;
        }
        $reported_script_name = basename($GLOBALS['PMA_PHP_SELF']);
        $found_error = false;
        $error_message = '';
        foreach ($params as $param) {
            if ($request && $param != 'db' && $param != 'table') {
                $checked_special = true;
            }
            if (!isset($GLOBALS[$param])) {
                $error_message .= $reported_script_name . ': ' . __('Missing parameter:') . ' ' . $param . self::showDocu('faq', 'faqmissingparameters', true) . '[br]';
                $found_error = true;
            }
        }
        if ($found_error) {
            PMA_fatalError($error_message, null, false);
        }
    }

Usage Example

コード例 #1
0
ファイル: sql.php プロジェクト: poush/phpmyadmin
 */
if (isset($_REQUEST['set_col_prefs']) && $_REQUEST['set_col_prefs'] == true) {
    PMA_setColumnOrderOrVisibility($table, $db);
    // script has exited at this point
}
// Default to browse if no query set and we have table
// (needed for browsing from DefaultTabTable)
$tableLength = mb_strlen($table);
$dbLength = mb_strlen($db);
if (empty($sql_query) && $tableLength && $dbLength) {
    $sql_query = PMA_getDefaultSqlQueryForBrowse($db, $table);
    // set $goto to what will be displayed if query returns 0 rows
    $goto = '';
} else {
    // Now we can check the parameters
    Util::checkParameters(array('sql_query'));
}
/**
 * Parse and analyze the query
 */
require_once 'libraries/parse_analyze.lib.php';
list($analyzed_sql_results, $db, $table) = PMA_parseAnalyze($sql_query, $db);
// @todo: possibly refactor
extract($analyzed_sql_results);
/**
 * Check rights in case of DROP DATABASE
 *
 * This test may be bypassed if $is_js_confirmed = 1 (already checked with js)
 * but since a malicious user may pass this variable by url/form, we don't take
 * into account this case.
 */
All Usage Examples Of PMA\libraries\Util::checkParameters
Util