Miva, Miva Script, Miva Empresa, Miva Mia amd Miva Merchant are registered trademarks of the Miva Corporation
 
Ivo Truxa - truXoft control systems: advanced programming and custom IT solutions home / about / webdesign / Miva / automation / contact

http://mivo.truxoft.com
MIVO!
miva beyond limits

 

MIVA®  RESOURCES: MimeConv 2.0

Copyright Version 1.0 (c) 1996 Nobby N Hirano, nobby@din.or.jp
Copyright Version 2.0 (c) 2008 Ivo Truxa, truXoft

Free for personal non-commercial use

  1. MimeConv 2.0 and file attachments in Miva
  2. Changes made in the version 2.0
  3. Known bugs, limitations and to-do's
  4. Calling Syntax
  5. Call Examples
  6. Use in Miva Scripts
  7. Security Notes
  8. Installation
  9. Packing List
  10. Legal Note
  11. Download
  12. User Comments

You can also read the older article and use the original version of MimeConv.


MimeConv 2.0 and file attachments in Miva

Version 2.0 of MimeConv was developed to enahnced functionality of applications written in Miva Script (http://miva.com), but may be use standalone or in connection with other script languages or CGI programs.

Features of MimeConv 2.0

  • Decoding (incoming mail attachments / MvPOP): base64 and quoted-printable
  • Encoding (outgoing mail attachments / MvSMTP): base64
  • Multiple file attachments (multi-part) supported in both ways
  • Supports direct calls through an URL (MvCALL) without any bridge perl/shell script
  • Extremly fast and easy to use
  • Precompiled binaries for PC Linux, Windows (32 bits) and DOS (16 bits)
  • May be used standalone or with any other script languages too

top


Changes made in the version 2.0

  • changed styling (just for my convenience)
  • optimizing and code cleaning
  • more comments added
  • change of function headers to the recent standard
  • moving of the qdec.c optimized functions into the base64.c
  • changes to be able to parse e-mails from Outlook
  • changes of the calling syntax (arguments) for CGI calls throgh an URL
  • changed help screen function
  • fix of malfunctional quoted printable decoding
  • fix of eventually possible buffer owerflows (security fix)
  • added configuration file with working directoery (for security reasons)
  • error handling improved
  • multi-part messages - single or multiple attachments & mixed encoding

top


Known bugs, limitations and to-do's

  • more security checks to do
  • does not accept spaces in file names (in the e-mail headers)

please report bugs to mime@truxoft.com

top


Calling Syntax


 http://domain/path/mimeconv?[mode+]source[+target]

   mode   = e   encode w/o MIME header (default)
   mode   = E   encode including MIME header
   mode   = d   decode
   source = path of file to decode/encode
   target = redirect output to a file (optional)

Replace the '?' and '+' signes with blanks when calling from a shell (e.g. Telnet or DOS Window)

top


Call Examples

encoding a binary file to the stdout (browser):

http://foobar.com/cgi-bin/mimeconv?subdir/order.dbf http://foobar.com/cgi-bin/mimeconv?e+order.dbf

encoding to a file:

http://foobar.com/cgi-bin/mimeconv?e+order.dbf+mime.tmp

decoding a source file:

http://foobar.com/cgi-bin/mimeconv?d+subdir/mail/MIVA_POP0000000A

In Telnet:   mimeconv d subdir/somefile.mvx

top


Use in Miva Scripts

Example of sending attachments with MvSMP

 <MvSMTP FROM="{from}" TO="{to}" SUBJECT="test" MAILHOST="localhost">
   <MvCALL ACTION="http://foo.bar/cgi-bin/mimeconv?E+user.dbf" METHOD="GET">
     <MvEVAL EXPR="{s.callvalue}">
   </MvCALL>
 </MvSMTP>

Example of extracting attachments with MvPOP

 <MvPOP MAILHOST="localhost" LOGIN="{log}" PASSWORD="{pswd}" DIRECTORY="{dir}">
   <MvASSIGN NAME="file" VALUE="{glosub(messagebody,dir $ '/','')}"> 
   <MvCALL ACTION="http://foo.bar/cgi-bin/mimeconv?d+&[file];" METHOD="GET">
   </MvCALL>
 </MvPOP>

Note: {dir} must point to the mimeconv directory, but in contrary to the mimeconv.ini it has to be relative to the Miva data directory!

You can find details of an implementation of both simple samples and a more advanced sending of multi-part e-mail messages with multiple file attachments in the mimeconv.mv sample file (also attached to the installation package).

top


Security Notes

mimeconv.ini file must be present in the same directory as mimeconv and must contain temporary working directory path where you want to store files to encode/decode. These files should be removed after encoding/decoding, because with help of this program they could be read from outside. There should be only a single line containing the working directory path with no leading nor traling whitespace. Please keep a trailing slah in the directory.

Never set the working directory to root, to cgi-bin or to some directory that has subdirectories with sensitive data or containing scripts or programs!

Also be aware, that if you keep the mimeconv.ini file empty, mimeconv will read and store fiels in the current directory - it means in the directory where it is installed. While it would be mostly your cgi-bin directory, it would mean a serious security hole in your configuration!

File permissions of mimeconv.ini should be set to be readable by the owner only - chmod 0400

Security of MimeConv was increased in version 2.0, but no exhaustive tests were made. Please be aware of potential security risks. Use the program only at own risk after carefully testing your configuration.

top


Installation

There are precompiled versions for PC Unix (compiled on Linux) and for Windows in the enclosed zip file. The program does not use any external libraries and therefore the binaries could work on most common systems. Recompiling for other then Intel processors should be possible. To recompile the program follow instructions in the Readme.txt file.

To install follow these steps:

  1. Unpack the files from the zip file
  2. Transfer the respective binary (mimeconv for Linux or mimeconv.exe for Windows) in binary mode to your cgi-bin directory
  3. Set the file permissions of the binary to 755 on Unix systems
  4. Edit the mimeconv.ini file. It must contain absolute (from server's root) or realtive (from the cgi-bin dir) path to an existing directory where you want to store encoded/decoded files. Please be sure to read the security note! Do not forget the trailing slash. Use backslash instead of slash on Windows systems.
  5. Transfer the mimeconv.ini in text mode to the same directory
  6. Set the file permissions of the mimeconv.ini to 400
  7. In a shell window (e.g. Telnet or DOS) go to the cgi-bin directory (e.g. cd www/cgi-bin) and type:  mimeconv  If you get the help screen without any error message, you are fine
  8. Now copy a file to the working directory (as written in mimeconv.ini) and type:  mimeconv yourfilename  If encoded characters run through the screen then you are OK.
  9. Copy the mimeconv.mv Miva sample script, edit the global settings and try all three examples
simply put the respective binary (mimeconv for Unix, mimeconv.exe for Windows) to your cgi-bin directory

NOTE: You can install multiple instances of the program. If you want to keep them in the same directory just rename both the binary and the configuration ini file respectively - in this way you can keep several configurations with different working directory settings.

top


Packing List


mimeconv.c    - C source for the MimeConv 2.x program
mimeconv      - UNIX (PC Linux) binary
mimeconv.exe  - Windows binary
mimeconv.com  - 16 bit DOS binary
mimeconv.ini  - sample configuration file
makefile.unix - makefile for GCC
makefile.win  - makefile for  MS C for Windows
Readme.txt    - this file
mimeconv.mv   - test Miva script

top


Legal Note

    The authors (Nobby N Hirano and Ivo Truxa) will not be liable for:
  • any bug, error, omission, defect, deficiency, or nonconformity in the product,
  • implied warranty of merchantability of fitness for a particular purpose,
  • implied warranty relating to course of performance, course of dealing, or usage of trade or any other implied warranty of any type whatsoever,
  • claim of infringement,
  • claim in tort, whether or not arising in whole or part from authors' fault, negligence, strict liability, or product liability, or (f) claim for any direct indirect, incidental, special, or consequential damages, or loss of data, revenue, customers goodwill, or use. in no case shall authors' liability exceed the suggested retail price for product.

top


Download

MimeConv 2.0 - binaries, C source and Miva examples - 48.2 kB
MimeConv 1.0 - original package from Nobby N Hirano - 29.8 kB


top

   

Miva and some other terms used on this page are registerd trademarks of the Miva Corporation
copyright  truXoft  © 1997-2008