wResponse::block

Blockiert eine Anfrage
(verfügbar ab CMS-Version 019.003.088.000)

Funktionsaufruf

Void block(String status, Array options)

Parameter

status
HTTP-Status
options
Optionen
title
Titel
info
Zusatzinfo
caller
Aufrufer

Beispiel: Beispiel 1: Blockiert eine Anfrage

Quelltext

<?php

require_once($_SERVER["DOCUMENT_ROOT"]."/weblication/grid.php");

$httpStatus = 400; //
$options    = array();

wResponse::block($httpStatus, $options);

?>

Beispiel: Beispiel 2: Blockiert Bot-Aufrufe (Auszug aus der wMyProject.php

Quelltext

<?php

// ...
public static function filterBots(){
  
  $botsToBlockRegExp = wVariables::getValue('bots_block_regExp', '', '/wGlobalProject/wGlobal/content/variables/default.wVariables.php', 'wDoNotAdd');          
  
  if($botsToBlockRegExp != ''){    
    if(preg_match('/'.$botsToBlockRegExp.'/i', $_SERVER['HTTP_USER_AGENT'])){
      wResponse::block(403, array('title' => 'Bad Request', 'anonymize' => false, 'info' => 'Bot protection, verification failed!', 'caller' => 'botHandler,type=filterBots'));
    }
  }
}
// ...

?>

Hinweis
Beim Einsatz von Framework-Funktionen in eigenen Skripten beachten Sie bitte den Artikel "So verwenden Sie das PHP-Framework in eigenen Scripten".
Wenn Sie eine Funktion innerhalb einer Weblication® Seite z.B. über das PHP-Quelltext Element oder in einem XSL-Template über wsl:php einbinden, muss das Framework über die grid.php nicht mehr referenziert werden.