X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FAjaxDispatcher.php;h=c9ca1283020bc0e585bdb6c3a2d1da4b23dafe76;hb=9b840c281cfae3c060941e45933e7798647064be;hp=5ee14a5007fafafcf486335242069e1da82fad7f;hpb=0fdb7455af6d5e42e88505911b1c912d2e55efc7;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/AjaxDispatcher.php b/includes/AjaxDispatcher.php index 5ee14a5007..c9ca128302 100644 --- a/includes/AjaxDispatcher.php +++ b/includes/AjaxDispatcher.php @@ -1,33 +1,55 @@ mode = "post"; } - switch( $this->mode ) { + switch ( $this->mode ) { case 'get': $this->func_name = isset( $_GET["rs"] ) ? $_GET["rs"] : ''; if ( ! empty( $_GET["rsargs"] ) ) { @@ -68,13 +90,14 @@ class AjaxDispatcher { wfProfileOut( __METHOD__ ); } - /** Pass the request to our internal function. + /** + * Pass the request to our internal function. * BEWARE! Data are passed as they have been supplied by the user, * they should be carefully handled in the function processing the * request. */ function performAction() { - global $wgAjaxExportList, $wgOut; + global $wgAjaxExportList, $wgUser; if ( empty( $this->mode ) ) { return; @@ -88,19 +111,18 @@ class AjaxDispatcher { wfHttpError( 400, 'Bad Request', - "unknown function " . (string) $this->func_name + "unknown function " . $this->func_name ); + } elseif ( !User::isEveryoneAllowed( 'read' ) && !$wgUser->isAllowed( 'read' ) ) { + wfHttpError( + 403, + 'Forbidden', + 'You are not allowed to view pages.' ); } else { wfDebug( __METHOD__ . ' dispatching ' . $this->func_name . "\n" ); - if ( strpos( $this->func_name, '::' ) !== false ) { - $func = explode( '::', $this->func_name, 2 ); - } else { - $func = $this->func_name; - } - try { - $result = call_user_func_array( $func, $this->args ); + $result = call_user_func_array( $this->func_name, $this->args ); if ( $result === false || $result === null ) { wfDebug( __METHOD__ . ' ERROR while dispatching ' @@ -134,6 +156,5 @@ class AjaxDispatcher { } wfProfileOut( __METHOD__ ); - $wgOut = null; } }