P3P Plugin

Last update: 2006-08-10

Adds a P3P header to the HTTP response.

Source code

Copyright (C) 2006 Tom N Harris This plugin is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This plugin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

action.php
<?php
/**
 * Send P3P header
 *
 * @license    GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
 * @author     Tom N Harris <tnharris [at] whoopdedo.org>
 */
// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();
 
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'action.php');
 
/**
 * All DokuWiki plugins to extend the actions
 * need to inherit from this class
 */
class action_plugin_p3p extends DokuWiki_Action_Plugin {
 
    /**
     * return some info
     */
    function getInfo(){
      return array(
        'author' => 'Tom N Harris',
        'email'  => 'tnharris [at] whoopdedo.org',
        'date'   => '2006-08-10',
        'name'   => 'P3P Plugin',
        'desc'   => 'Send P3P header',
        'url'    => 'http://whoopdedo.org/doku/wiki/p3p',
      );
    }
 
    function register(&$controller) {
      $controller->register_hook('ACTION_HEADERS_SEND','BEFORE', $this, 'process_event', NULL);
    }
 
    /**
     * handle user request
     */
    function process_event(&$event, $param) {
      $policy = $this->getConf('policyref');
      $compact = $this->getConf('compact_policy');
      if(!empty($policy)){
        $hdr = 'P3P: policyref="'.$policy.'"';
        if(!empty($compact))
          $hdr .= 'CP="'.$compact.'"';
        $event->data[] = $hdr;
      }
    }
 
}