Posted By


FazzyX on 12/08/10

Tagged


Statistics


Viewed 309 times
Favorited by 0 user(s)

pageNotFoundHandling


/ Published in: PHP
Save to your folder(s)

<p>TYPO3 pageNotFoundHandling with determination of 404 and 401/403 stats. </p>

<p>Modify LOGIN_URL and NOTFOUND_URL !</p>

<p>Save as pageNotFoundHandling.php and point to this from Install Tool setting.</p>

<p>[FE][pageNotFound_handling] = USER_FUNCTION:fileadmin/scripts/pageNotFoundHandling.php:user_pageNotFound->pageNotFound</p>

<p>Enable cURL by setting [SYS][curlUse] = 1 at Install Tool</p>

<p>cURL must provide from system !</p>

<p>To get redirected after login to the request page, you have to use 'defined by GET/POST-Vars' at felogin redirect mode</p>


Copy this code and paste it in your HTML
  1. <?php
  2. define(LOGIN_URL, "http://domain.tld/login.html");
  3. define(NOTFOUND_URL, "http://domain.tld/not-found.html");
  4.  
  5. class user_pageNotFound {
  6. function pageNotFound($param, $ref) {
  7. if ($param["pageAccessFailureReasons"]["fe_group"] != array(""=>0)) {
  8. header("HTTP/1.0 403 Forbidden");
  9. $url = LOGIN_URL."?redirect_url=" . $param["currentUrl"];
  10. } else {
  11. $url = NOTFOUND_URL;
  12. }
  13.  
  14. $strCookie = 'PHPSESSID=' . $_COOKIE['PHPSESSID'] . '; path=/';
  15.  
  16. $c = curl_init();
  17. curl_setopt($c, CURLOPT_URL, $url);
  18. curl_setopt($c, CURLOPT_COOKIE, $strCookie);
  19. $contents = curl_exec($c);
  20.  
  21. if ($contents) return $contents;
  22. else return FALSE;
  23. }
  24. }
  25. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.