RalphThesen - Code Snippets
Suggestion fpr FilesAction
FilesAction with the correct MIME Header (based upon mimes.txt)
Replace line 16:
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);
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;
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
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).
Content-Disposition: inline; would be send instead off Content-Disposition: attachment;
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. :)
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.
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.