Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



validate_file ›

Seit1.2.0
Veraltetn/v
validate_file ( $file, $allowed_files = '' )
Parameter: (2)
  • (string) $file File path.
    Erforderlich: Ja
  • (array) $allowed_files List of allowed files.
    Erforderlich: Nein
    Standard: (leer)
Gibt zurück:
  • (int) 0 means nothing is wrong, greater than 0 means something was wrong.
Definiert in:
Codex:

File validates against allowed set of defined rules.

A return value of '1' means that the $file contains either '..' or './'. A return value of '2' means that the $file contains ':' after the first character. A return value of '3' means that the file is not in the allowed files list.



Quellcode

function validate_file( $file, $allowed_files = '' ) {
	if ( false !== strpos( $file, '..' ) )
		return 1;

	if ( false !== strpos( $file, './' ) )
		return 1;

	if ( ! empty( $allowed_files ) && ! in_array( $file, $allowed_files ) )
		return 3;

	if (':' == substr( $file, 1, 1 ) )
		return 2;

	return 0;
}