RalphThesen - Code Snippets


Suggestion fpr FilesAction


FilesAction with the correct MIME Header (based upon mimes.txt)

Replace line 16:
            Header("Content-Type: application/x-download");

with the following lines :
        // Examine Suffix
          if (preg_match("/.*\.(\w+)$/i",$filename,$res))
            $suffix=$res[1];
          // Search MIME Type
            if (!$suffix || $suffix=="" || !$this->config['mime_types']
               || !$mimes=implode("\n",file($this->config['mime_types'])))
               $content_type="application/x-download";
            else {
               if (preg_match("/([A-Za-z\/-]*).*$suffix/i",$mimes,$result))
                  $content_type=$result[1];
               else
                  $content_type="application/x-download";
            }
          Header("Content-Type: ".$content_type);


Suggestion for ImageAction


A feature for the ImageAction would be, if you can use (via FilesAction) uploaded Images. To implement this add the following line after line 26 in action/image.php

// Enable upload='uploadedimage.extension'
if ($param == 'upload' and $vars['url'] == '')
$vars['url']=$this->GetConfigValue('upload_path').'/'.$this->GetPageTag().'/'.$value;


Example
{{image class="center" alt="Uploaded Image" title="The Image Title" upload="imagename.extension"}}

http://redimp.de/ImageActionUpload

To use this, you need a different htacces file.

Suggestion for a new htaccess File


This htaccess file allows the Browser to fetch existing files below the wikka root, even if rewrite is enabled. If you want to place subfolders below your wikka root with other projects/files/whatever, you can use this .htaccess too. For more Details see HtaccessConfig.

### STOP REFERRER SPAM
SetEnvIfNoCase Referer ".*(adultsite|picturesplace|learnthebiz|pi-o|erotica|ghettoinc|port5|bulk-email|camgirls|paris-hilton|modelos|kredit|handyflirt24|versicherung|wwww|erotower|krank|x-1000|flirtnet|blowjob|agedwife|in-the-vip|boysfirsttime|milf|captain-stabbin|tranny|Kontakt|erotik|fetish|frauen|hardcore|fick|krankenversicherung|jinnan-cross|8thstreet|xxx|XXX|ficken|fuck).*" BadReferrer

order deny,allow
deny from env=BadReferrer

## Enhanced Rewrite
<IfModule mod_rewrite.c>
 RewriteEngine on
## If the target is a directory and the trailing Slash is missing, append a Slash 
 RewriteCond %{REQUEST_FILENAME} -d
 RewriteRule ^(.*/[^\./]*[^/])$ $1/ [L]
## If the file doesn't exist, forward to wikka.php 
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule ^(.*)$ wikka.php?wakka=$1 [QSA,L]
</IfModule>




CategoryUsers
Comments
Comment by JavaWoman
2005-01-27 05:02:34
Ralph,
Can you explain what is your intention with this change?

MIME type application/x-download is used to tell the browser to actually *download* the file, even if it is of a type that can be displayed in the browser (or might be executed).
Comment by RalphThesen
2005-01-27 08:19:44
Ehm, the first intention was to use the mime_types file ... the second was to tell the browser the right mime type. Hmm. I should add to the patch that you can set an option with the FilesAction that the file can be displayed in the Browser.

Content-Disposition: inline; would be send instead off Content-Disposition: attachment;
Comment by JavaWoman
2005-06-03 14:47:09
Ralph,

It would be simpler if the image action, when given nothing but a file name, would simply *look* in the page's uploads directory (as well as the /images directory) without needing an extra parameter.
As to .htaccess, see also HtaccessConfig, the development page for (a new) .htaccess file. :)
Comment by RalphThesen
2005-06-03 15:39:49
e.g. {{image url="bla.jpg"}} should look for bla.jpg in $this->GetConfigValue('upload_path').'/'.$this->GetPageTag()
and if nothing found in
'images/'
for the file and set $vars['url'] to the right path. i will add these features to the ImageAction, soon.
Comment by 62-101-126-218.fastres.net
2005-06-03 17:17:23
Hi Ralph!
You may want to take a look at EnhancedImageAction for the development of the image-action. Thank you for your contributions, but to make them easier to find for other people, please place links to this page on the appropriate development-pages (and add CategoryUsers to your page :) . You might want to add youself to the UserMap, too.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki