Hash Action


Creates an MD5 and/or SHA1 hash of the page body it's embedded in. The hash value is calculated from the wiki markup, so it should uniquely identify each page revision regardless of formatting applied to the markup. Currently in use on the OpenNIC wiki [requires access to OpenNIC DNS.

actions/hash/hash.php
<?php
/**
 * Calculate a hash value for the page body.
 *
 * Hash value is calculated against the stringified version of the
 * wiki markup, not the formatted output.  Therefore, restoration of
 * older page version should generate the same hash values independent
 * of any CSS/formatter modifications.
 *
 * Syntax: {{hash type="md5"}} (Generates MD5 sum for page body)
 *         {{hash type="sha1"}} (Generates SHA1 sum for page body)
 *
 * @package     Actions
 * @version     $Id$
 * @license     http://www.gnu.org/copyleft/gpl.html GNU General
 *              Public License
 * @filesource
 * @author      {@link http://wikkawiki.org/BrianKoontz Brian Koontz}
 *
 */

    if("md5" === $vars['type'])
        print md5($this->htmlspecialchars_ent($this->page['body']));
    else if("sha1" === $vars['type'])
        print sha1($this->htmlspecialchars_ent($this->page['body']));
    else
        print "<em class=\"error\">Invalid hash type</em>";
?>



CategoryUserContributions
There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki