<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.creativecommons.org/index.php?action=history&amp;feed=atom&amp;title=Cchost%2Fdeveloper%2Ftutorial%2FReplacing_the_File_Verifier</id>
		<title>Cchost/developer/tutorial/Replacing the File Verifier - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.creativecommons.org/index.php?action=history&amp;feed=atom&amp;title=Cchost%2Fdeveloper%2Ftutorial%2FReplacing_the_File_Verifier"/>
		<link rel="alternate" type="text/html" href="https://wiki.creativecommons.org/index.php?title=Cchost/developer/tutorial/Replacing_the_File_Verifier&amp;action=history"/>
		<updated>2026-04-22T17:36:04Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>https://wiki.creativecommons.org/index.php?title=Cchost/developer/tutorial/Replacing_the_File_Verifier&amp;diff=19729&amp;oldid=prev</id>
		<title>Fourstones at 10:50, 12 November 2008</title>
		<link rel="alternate" type="text/html" href="https://wiki.creativecommons.org/index.php?title=Cchost/developer/tutorial/Replacing_the_File_Verifier&amp;diff=19729&amp;oldid=prev"/>
				<updated>2008-11-12T10:50:28Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 10:50, 12 November 2008&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l4&quot; &gt;Line 4:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 4:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Software]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Software]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Technology]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Technology]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;draft&lt;/del&gt;}}&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;cchost_head&lt;/ins&gt;}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{lowercase}}&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{lowercase}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;{{Infobox|NOTE: This code is untested. It is only theoretical until someone can verify it works as advertised.}}&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The ccHost philosophy for file verifying is a whitelist - a list of file types to be accepted, all others rejected. At least one installation has chosen to implement a blacklist instead. The portable way to do this is to use ccHost's verify hook - basically a global variable.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The ccHost philosophy for file verifying is a whitelist - a list of file types to be accepted, all others rejected. At least one installation has chosen to implement a blacklist instead. The portable way to do this is to use ccHost's verify hook - basically a global variable.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Fourstones</name></author>	</entry>

	<entry>
		<id>https://wiki.creativecommons.org/index.php?title=Cchost/developer/tutorial/Replacing_the_File_Verifier&amp;diff=19620&amp;oldid=prev</id>
		<title>Fourstones: New page: Category:ccHost Category:ccMixter Category:Developer Category:Software Category:Technology {{draft}} {{lowercase}} {{Infobox|NOTE: This code is untested. It is only the...</title>
		<link rel="alternate" type="text/html" href="https://wiki.creativecommons.org/index.php?title=Cchost/developer/tutorial/Replacing_the_File_Verifier&amp;diff=19620&amp;oldid=prev"/>
				<updated>2008-11-06T20:21:25Z</updated>
		
		<summary type="html">&lt;p&gt;New page: &lt;a href=&quot;/wiki/Category:CcHost&quot; title=&quot;Category:CcHost&quot;&gt;Category:ccHost&lt;/a&gt; &lt;a href=&quot;/wiki/Category:CcMixter&quot; title=&quot;Category:CcMixter&quot;&gt;Category:ccMixter&lt;/a&gt; &lt;a href=&quot;/wiki/Category:Developer&quot; title=&quot;Category:Developer&quot;&gt;Category:Developer&lt;/a&gt; &lt;a href=&quot;/wiki/Category:Software&quot; title=&quot;Category:Software&quot;&gt;Category:Software&lt;/a&gt; &lt;a href=&quot;/wiki/Category:Technology&quot; title=&quot;Category:Technology&quot;&gt;Category:Technology&lt;/a&gt; {{draft}} {{lowercase}} {{Infobox|NOTE: This code is untested. It is only the...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:ccHost]]&lt;br /&gt;
[[Category:ccMixter]]&lt;br /&gt;
[[Category:Developer]]&lt;br /&gt;
[[Category:Software]]&lt;br /&gt;
[[Category:Technology]]&lt;br /&gt;
{{draft}}&lt;br /&gt;
{{lowercase}}&lt;br /&gt;
{{Infobox|NOTE: This code is untested. It is only theoretical until someone can verify it works as advertised.}}&lt;br /&gt;
The ccHost philosophy for file verifying is a whitelist - a list of file types to be accepted, all others rejected. At least one installation has chosen to implement a blacklist instead. The portable way to do this is to use ccHost's verify hook - basically a global variable.&lt;br /&gt;
&lt;br /&gt;
The following code is a skeleton of how to hook the system. The actual blacklisting algorithm is left as an exercise for the reader. Put this code into a file '''&amp;lt;local_files&amp;gt;/lib/blacklist_validator.php''':&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;nowiki&amp;gt;&amp;lt;?&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
    // the uploader looks for this variable:&lt;br /&gt;
 &lt;br /&gt;
    global $CC_UPLOAD_VALIDATOR;&lt;br /&gt;
 &lt;br /&gt;
    // set the global to our validator factory...&lt;br /&gt;
 &lt;br /&gt;
    $CC_UPLOAD_VALIDATOR = 'make_blacklist_validator';&lt;br /&gt;
  &lt;br /&gt;
    function make_blacklist_validator()&lt;br /&gt;
    {&lt;br /&gt;
        return new Blacklist_Validator(true); // set this to false if you don't want to &lt;br /&gt;
                                              // delegate to the system's validator&lt;br /&gt;
    }&lt;br /&gt;
 &lt;br /&gt;
    /**&lt;br /&gt;
    * Blacklist_Validator &lt;br /&gt;
    *&lt;br /&gt;
    * Replace (or override) the existing whitelist base verifier&lt;br /&gt;
    * with an alternate version&lt;br /&gt;
    *&lt;br /&gt;
    */&lt;br /&gt;
    class Blacklist_Validator &lt;br /&gt;
    {&lt;br /&gt;
        var $old_validator;  // store a pointer to the system validator&lt;br /&gt;
        var $do_delegation;  // flag as to whether to delegate to the system.&lt;br /&gt;
 &lt;br /&gt;
        function Blacklist_Validator($do_delegation=true)&lt;br /&gt;
        {&lt;br /&gt;
            $this-&amp;gt;do_delegation = $do_delegation;&lt;br /&gt;
 &lt;br /&gt;
            if( $this-&amp;gt;do_delegation )&lt;br /&gt;
            {&lt;br /&gt;
               require_once('cchost_lib/ccextras/cc-pseudo-verify.inc');&lt;br /&gt;
               $this-&amp;gt;old_validator = new CCPseudoVerifyAPI();&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
 &lt;br /&gt;
        function GetValidFileTypes(&amp;amp;$types)&lt;br /&gt;
        {&lt;br /&gt;
            if( $this-&amp;gt;do_delegation )&lt;br /&gt;
            {&lt;br /&gt;
               $retval = $this-&amp;gt;old_validator-&amp;gt;GetValidFileTypes($types);&lt;br /&gt;
            }&lt;br /&gt;
            else&lt;br /&gt;
            {&lt;br /&gt;
               $retval = true;&lt;br /&gt;
            }&lt;br /&gt;
 &lt;br /&gt;
            $types[] = '*.*';&lt;br /&gt;
            return $retval;&lt;br /&gt;
        }&lt;br /&gt;
 &lt;br /&gt;
        function FileValidate(&amp;amp;$formatinfo)&lt;br /&gt;
        {&lt;br /&gt;
            if( $this-&amp;gt;do_delegation )&lt;br /&gt;
            {&lt;br /&gt;
               $retval = $this-&amp;gt;old_validator-&amp;gt;FileValidate($formatinfo);&lt;br /&gt;
               if( $retval )&lt;br /&gt;
                  return true;&lt;br /&gt;
            }&lt;br /&gt;
            else&lt;br /&gt;
            {&lt;br /&gt;
                if( !is_array( $types ) )&lt;br /&gt;
                  $types = array();&lt;br /&gt;
                $retval = false;&lt;br /&gt;
            }&lt;br /&gt;
 &lt;br /&gt;
            $path = $formatinfo-&amp;gt;GetFilePath();&lt;br /&gt;
 &lt;br /&gt;
            // things really break down if we don't have a&lt;br /&gt;
            // file extension so we just reject them out&lt;br /&gt;
            // of hand&lt;br /&gt;
 &lt;br /&gt;
            $got_ext = &amp;lt;nowiki&amp;gt;preg_match( '/\.([a-z0-9]+)$/', strtolower($path), $m )&amp;lt;/nowiki&amp;gt;;&lt;br /&gt;
 &lt;br /&gt;
            if( !$got_ext )&lt;br /&gt;
            {&lt;br /&gt;
                $formatinfo-&amp;gt;SetErrors( _('Cannot determine file type'));&lt;br /&gt;
                return false;&lt;br /&gt;
            }&lt;br /&gt;
 &lt;br /&gt;
            /*********************************** &lt;br /&gt;
             *   Edit the code below here...   *&lt;br /&gt;
             ***********************************/&lt;br /&gt;
 &lt;br /&gt;
            $retval = 1 ? true : false; // &amp;lt;&amp;lt;&amp;lt;---- your verification code goes here&lt;br /&gt;
 &lt;br /&gt;
            if( $retval )&lt;br /&gt;
            {&lt;br /&gt;
                $FI['tags']         = 'archive,' . $m[0];   // tags here will be added to &lt;br /&gt;
                $FI['default-ext']  = $m[0];                // your default extension goes here&lt;br /&gt;
                $FI['media-type']   = 'archive';            // media type (e.g. video, audio, image, archive, etc.)&lt;br /&gt;
                $FI['mime_type']    = 'octect/stream';      // or whatever you think&lt;br /&gt;
 &lt;br /&gt;
                $formatinfo-&amp;gt;SetData( $FI );&lt;br /&gt;
                $formatinfo-&amp;gt;_errors = &amp;lt;nowiki&amp;gt;''&amp;lt;/nowiki&amp;gt;;&lt;br /&gt;
            }&lt;br /&gt;
 &lt;br /&gt;
            return $retval;&lt;br /&gt;
        }&lt;br /&gt;
 &lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;nowiki&amp;gt;?&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Fourstones</name></author>	</entry>

	</feed>