=====twomcm's user page===== These are two Wikka modules i have written. - The first, which i call 'blob', allows you to upload files ( up to 1 MiB (MySQL packet limit)) to a wikka powered site. As well, you can embed images into pages, create a link to the file, or show a description ( incl of view/download link ). It uses two files but the action file is all that is required if you only wish to upload or show the description view for files. - The second ( base64.php ) allows small files to be embeded into a page if they are base64 encoded ( not really suggested to be used ). Enjoy. Any comments would be appreciated. Since i do not have access to Internet Exploder YMMV if you are accessing these page with //that// browser. [[http://img82.imageshack.us/img82/7196/fileupload8kt.png | Screen shot of an example]] ( due to image editing problems, "Standard file embed" has Type: and Size: duplicated ). =====If you want to contact me use [[paranoidgeek@gmail.com]]===== I doubt if i will be visting this page often. =====Blob details :===== Blob ( as i have called it ) is [[Wikipedia:SHA1 | hash]] orientated. The three modes for displaying the file are : 1) **Description.** This gives a box with the file's details and allows has view and download buttons. Exmaple code : ""{{blob hash="SHA1 SUM"}}"" 1) **Image embed**. This inserts the image as ####. Also 'wrapped' with an #### pointing to the same URL as the img src. Requires the handerler file installed and the file's type must start with 'image' ( e.g. image/png). Example code : ""{{blob hash="SHA1 SUM" type="image"}}"" 1) **Image with border**. Same as above but with a border ( using class="border" ). Example code : ""{{blob hash="SHA1 SUM" type="image_wb"}}"" 1) **Link**. Just the file name wrapped with a #### pointing to the file's view URL. ---- ##/action/blob.php## %%(php) @author-nick twomcm @date November 2005 @version 1.1 @changlog 1.3 Image + link 1.2 Changed so that it will only allow uploads if the user has R/W to the page. 1.1 Minor bugs fixed 1.0 Complete 0.1 blank @license GPL v 2 @example List {{blob list="yes"}} Display {{blob hash="SHA1 SUM"}} Image {{blob hash="SHA1 SUM" type="image"}} link {{blob hash="SHA1 SUM" type="link"}} */ if($_POST['blob_sha1'] && !$_POST['blob_delete']){ // get file $row = $this->LoadSingle("SELECT LENGTH(`data`) as `size`, `hash`, `name`, `type`, `data` ". "FROM ".$this->config["table_prefix"]."blob WHERE `hash` = '".mysql_escape_string($_POST['blob_sha1'])."' "); if($row){ while(@ ob_end_clean()); // clean out every thing. header("Content-Length: ".$row['size']); header("Pragma: no-cache"); header("Content-Type: ".$row['type']); if($_POST['download'] ) header('Content-Disposition: attachment; filename="'.$row['name'].'"'); echo $row['data']; die(); }else{ while(@ ob_end_clean()); echo "Sorry the system was unable to find the requested item. \n"; die(); } }elseif(is_array($vars) && $vars['hash']){ $row = $this->LoadSingle("SELECT LENGTH(`data`) as `size`, `hash`, `name`, `type`, `upload_date` ". "FROM ".$this->config["table_prefix"]."blob WHERE `hash` = '".mysql_escape_string($vars['hash'])."' "); if($row){ if(strtolower($vars['type']) == 'link'){ echo "href('blob',$this->GetPageTag(),'action=view&hash='.$row['hash'])."\">"; echo "{$row['name']}"; echo ""; }elseif(strtolower($vars['type']) == 'image'){ echo "href('blob',$this->GetPageTag(),'action=view&hash='.$row['hash'])."\">"; echo " href('blob',$this->GetPageTag(),'action=view&hash='.$row['hash'])."\" />"; echo ""; }else{ echo $this->FormOpen(); echo "
Hash | Name | Type | Size | Upload Date | |||
---|---|---|---|---|---|---|---|
{$row['hash']} | ". "{$row['name']} | ". "{$row['type']} | ". "{$row['size']} | ". "".date("Y F j, G:i:s", strtotime($row['upload_date']))." | "; echo ''; echo $this->FormOpen(); echo '\n"; echo ''; echo $this->FormClose(); echo ' | '."\n"; // view echo ''; echo $this->FormOpen(); echo '\n"; echo ''; echo $this->FormClose(); echo ' | '."\n"; // download echo ''; if($this->HasAccess("write")){ echo $this->FormOpen(); echo '\n"; echo ''; // delete + js confirm echo $this->FormClose(); } echo ' | '."\n"; echo "