root/drupal-module/auquotidien.theme.inc @ 507079e2
| 0bb989f9 | Frédéric Péters | <?php
|
|
require_once "ProxyHandler.class.php";
|
|||
function template_preprocess_auquotidien(&$variables) {
|
|||
$variables['message'] = check_markup(variable_get('auquotidien_message', ''),
|
|||
variable_get('auquotidien_message_format',
|
|||
FILTER_FORMAT_DEFAULT));
|
|||
$path = isset($_GET['q']) ? $_GET['q'] : '<front>';
|
|||
$link = $_SERVER['REQUEST_URI'];
|
|||
$base_root = url('<front>');
|
|||
if ($link == $base_root . 'auquotidien') {
|
|||
// missing slash
|
|||
header('Location: ' . $link . '/');
|
|||
return;
|
|||
}
|
|||
$proxied_url = substr($link, strlen($base_root . 'auquotidien'));
|
|||
$auquo_url = rtrim(variable_get('auquotidien_url', ''), '/');
|
|||
if ($auquo_url == '') {
|
|||
$variables['content'] = t('Not configured yet.');
|
|||
return;
|
|||
}
|
|||
$proxy = new ProxyHandler($base_root . 'auquotidien/', $auquo_url, $proxied_url);
|
|||
$proxy->setClientHeader('X-WCS-Iframe-Mode: true');
|
|||
$proxy->setClientHeader('X-WCS-Drupal-Mode: true');
|
|||
if ($GLOBALS['user']->uid != 0) {
|
|||
$proxy->setClientHeader('X-WCS-Drupal-User-Uid: ' . $GLOBALS['user']->uid);
|
|||
$proxy->setClientHeader('X-WCS-Drupal-User-Name: ' . $GLOBALS['user']->name);
|
|||
$proxy->setClientHeader('X-WCS-Drupal-User-Mail: ' . $GLOBALS['user']->mail);
|
|||
}
|
|||
$proxy->execute();
|
|||
$proxy->close();
|
|||
if ($proxy->http_code == 404) {
|
|||
return drupal_not_found();
|
|||
}
|
|||
if ($proxy->http_code == 301 || $proxy->http_code == 302 || $proxy->http_code == 303) {
|
|||
if (trim($proxy->location) == 'Location:') {
|
|||
$proxy->location = 'Location: ' . $base_root . 'auquotidien/';
|
|||
}
|
|||
header($proxy->location);
|
|||
return;
|
|||
}
|
|||
preg_match('/(<div id="main-content">.*)<\/body>/s', $proxy->result, $re_content);
|
|||
$content = $re_content[1];
|
|||
$variables['content'] = $content;
|
|||
}
|
|||
?>
|