Skip to content

Instantly share code, notes, and snippets.

@christianhaendel
Created June 11, 2016 15:12
Show Gist options
  • Select an option

  • Save christianhaendel/e2d5bacd733aec6d491ec36a8d00c61d to your computer and use it in GitHub Desktop.

Select an option

Save christianhaendel/e2d5bacd733aec6d491ec36a8d00c61d to your computer and use it in GitHub Desktop.

Revisions

  1. t3agent revised this gist Jun 11, 2016. No changes.
  2. t3agent created this gist Jun 11, 2016.
    36 changes: 36 additions & 0 deletions pageNotFoundHandling.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    <?php

    class user_pageNotFound {
    function pageNotFound($params,$tsfeObj) {
    global $TYPO3_CONF_VARS;

    $url = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL').'index.php?id='.$TYPO3_CONF_VARS['EXTCONF']['realurl'][\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('HTTP_HOST')]['errorPage'];

    $_buffer = $this->loadPage($url);
    echo $_buffer;
    }

    function loadPage($url) {
    $agent = "TYPO3 pageNotFoundFunction v1.0";
    $header[] = "Accept: text/vnd.wap.wml,*.*";
    $ch = curl_init($url);

    if ($ch) {
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_USERAGENT, $agent);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

    $tmp = curl_exec($ch);

    if(FALSE == $tmp) {
    print_r(curl_error($ch));
    }

    curl_close($ch);
    }
    return $tmp;
    }
    }

    ?>