MivaScript Functions

Name -- Syntax / Description
abs
abs( number )
Returns the absolute value of number.
acos
acos( number )
Returns the arccosine of number. The results are returned in radians.
asciichar
asciichar( number )
Returns the character corresponding to ascii character code in number. (number must be less than 255).
asciivalue
asciivalue( character )
Returns the ASCII numeric value for character (character must be a single character).
asin
asin( number )
Returns the arcsine of number. The results are returned in radians.
atan
atan( number )
Returns the arctangent of number. The results are returned in radians.
atan2
atan2( x, y )
Returns the arctangent of y/x. This is similar to atan(), but the signs of y and x are taken into account when computing the quadrant of the result. The results are returned in radians.
bf_decrypt
bf_decrypt( key, encrypted, plaintext var )
Blowfish decryption
Returns 1 on success, 0 on error
  • key = the encryption key in ECB mode. the key must be 16 characters.
  • plaintext = the text thats encrypted
  • encrypted = if sucessful it will contain the results
bf_encrypt
bf_encrypt( key, plaintext, encrypted var )
Blowfish encryption
Returns 1 on success, 0 on error
  • key = the encryption key in ECB mode. The key must be 16 characters.
  • plaintext = the text thats encrypted
  • encrypted = if sucessful it will contain the results
ceil
ceil( number )
Returns the smallest integer greater than or equal to number
cos
cos( number )
Returns the cosine of number. The argument should be expressed in radians.
cosh
cosh( number )
Returns the hyperbolic cosine of number. The argument should be expressed in radians.
crypto_base64_decode
crypto_base64_decode( data )
Decodes and returns Base-64 decodes data.
Returns the decrypted data
  • data = the information to decode
crypto_base64_encode
crypto_base64_encode( data )
Encodes and returns Base-64 encoded data.
Returns the encrypted data
  • data = the information to encode
crypto_cipher_block_size
crypto_cipher_block_size( ciphername )
Programatically determine the block size attribute of the cipher specified by "ciphername".
returns the numeric size, in bytes, or -1 if an invalid "ciphername" is specified.
  • ciphername = an OpenSSL cipher identifier, such as "aes-128-cbc" or "rc2-ofb".
crypto_cipher_iv_length
crypto_cipher_iv_length( ciphername )
Programatically determine the iv_length attribute of the cipher specified by "ciphername".
returns the numeric size, in bytes, or -1 if an invalid "ciphername" is specified.
  • ciphername = an OpenSSL cipher identifier, such as "aes-128-cbc" or "rc2-ofb".
crypto_cipher_key_length
crypto_cipher_key_length( ciphername )
Programatically determine the key_length attribute of the cipher specified by "ciphername".
returns the numeric size, in bytes, or -1 if an invalid "ciphername" is specified.
  • ciphername = an OpenSSL cipher identifier, such as "aes-128-cbc" or "rc2-ofb".
crypto_cipher_mode
crypto_cipher_mode( ciphername )
Returns the block mode of operation of the cipher specified by "ciphername."
  • where ciphername = an OpenSSL cipher identifier, such as "aes-128-cbc" or "rc2-ofb"
crypto_digest_block_size
crypto_digest_block_size( digestname )
Programatically determines the block_size attribute of the digest algorithm specified by "digestname".
Returns the numeric size, in bytes, or -1 if an invalid "digestname" is specified.
  • digestname = an OpenSSL digest identifier, such as "sha256" or "md5".
crypto_digest_size
crypto_digest_size( digestname )
Programatically determines the digest_size attribute of the digest algorithm specified by "digestname".
Returns the numeric size, in bytes, or -1 if an invalid "digestname" is specified.
  • digestname = an OpenSSL digest identifier, such as "sha256" or "md5".
crypto_evp_decrypt
crypto_evp_decrypt( ciphername, key, iv, encrypted, plaintext var )
Decrypts "plaintext" using the block cipher specified by "ciphername", placing the decrypted data into "plaintext".
Return 1 on success, 0 on failure.
  • ciphername = The OpenSSL identifier of the cipher, such as "bf-cbc" or "des-ede3-cbc".
  • key = The key used for encryption.
  • iv = The initialization vector used for encryption. returned by crypto_cipher_iv_length().
  • encrypted = The ciphertext to be decrypted
  • plaintext = [output] Receives the plaintext
crypto_evp_digest
crypto_evp_digest( digestname, buffer var, digest var )
Calculates the digest of "buffer" using digest algorithm "digestname", placing the calculated digest in "digest". The digest output is always in raw binary format, use miva_hex_encode() or crypto_base64_encode() if other output formats are desired.
Returns 1 on success or 0 if an invalid or unsupported "digestname" is specified.
  • digestname = an OpenSSL digest identifier, such as "sha256" or "md5". buffer =
  • digest =
crypto_evp_encrypt
crypto_evp_encrypt( ciphername, key, iv, plaintext, encrypted var )
Encrypts "plaintext" using the block cipher specified by "ciphername", placing the encrypted data into "encrypted".
returns 1 on success, 0 on failure
  • ciphername = The OpenSSL identifier of the cipher, such as "bf-cbc" or "des-ede3-cbc".
  • key = The encryption key. Must be exactly the number of bytes required by the cipher, as returned by crypto_cipher_key_length.
  • iv = An initialization vector, if required by the cipher. Must be exactly the number of bytes required by the cipher, as returned by crypto_cipher_iv_length.
  • plaintext = The text to be encrypted
  • encrypted = [output] Receives the cipher text
crypto_evp_hmac
crypto_evp_hmac( digestname, key, buffer var, digest var )
Calculates the HMAC of "buffer" using digest algorithm "digestname" and key "key", placing the HMAC in "digest". The HMAC output is always in raw binary format, use miva_hex_encode() or crypto_base64_encode() if other output formats are desired.
Returns 1 on success or 0 if an invalid or unsupported "digestname" is specified.
  • digestname = an OpenSSL digest identifier, such as "sha256" or "md5".
  • buffer = The data that will be process.
  • digest = The result of the HMAC function.
crypto_hmac_md5
crypto_hmac_md5( buffer var, key, format, result var )
Performs an HMAC-MD5 on "buffer" using key "key", storing the result in "result".
Returns 1 on success, 0 on error.
  • buffer = the data that will be processed.
  • key = the encryption key
  • format = on of the literal string "hex" or "binary"
  • result = the return data.
crypto_hmac_sha1
crypto_hmac_sha1( value, key, output_format, output)
Calculates an HMAC SHA-1 (Hash-based Message Authentication Code) of value
returns: 1 on success, 0 on failure (including OpenSSL not being available)
  • value = value to hash by reference
  • key = key to use to calculate the hmac
  • output_format = 'hex' or 'binary'
  • output = hmac_sha1 hash value.
crypto_hmac_sha256
crypto_hmac_sha256( buffer var, key, format, result var )
Calculates an HMAC SHA-256 (Hash-based Message Authentication Code) of buffer
Returns 1 on success, 0 on error or if on an unsuported platform.
  • buffer = value to hash
  • key = binary key to use to calculate the hmac
  • format = "binary" or "hex"
  • result = a variable used to store the results.
crypto_last_error
crypto_last_error()
Returns the error text from the last SSL error, or other internal errors in the crypto suite of functions. Use crypto_last_ssl_error() instead to get the code of the last SSL error.
Returns error text.
crypto_last_ssl_error
crypto_last_ssl_error()
Returns the Integer value of the last SSL error code. Use crypto_last_error() instead to get the text of the last SSL error.
Returns error code.
crypto_library_version
crypto_library_version( info )
crypto_md5
crypto_md5( buffer )
Calculates the MD5 hash of a string.
Returns the MD5 hash value.
  • buffer = the data to be hashed.
crypto_md5_file
crypto_md5_file( file, location, hash var )
Calculates the md5 hash of a file
Returns 1 on success, 0 on failure.
  • file = Name of file to calculate the hash of
  • location = Location either "script" or "data"
  • hash = MD5 hash value
crypto_pbkdf1
crypto_pbkdf1( digestname, password, salt, iterations, dklen, dk var )
Derives a key of "dklen" bytes using PBKDF1 from PKCS #5.
Returns 1 on success or 0 on error.
  • digestname = The digest algorithm to use. Must be one of "md2", "md5" or "sha1". password = The password from which a key is to be derived.
  • salt = Exactly 8 bytes of random data that are used as a salt.
  • iterations = The number of iterations to perform.
  • dklen = The desired output length of the derived key. May not be longer than the output digest size of the specified digest algorithm.
  • dk = [output] Receives the derived key. The output is in raw binary.
crypto_pbkdf2
crypto_pbkdf2( digestname, password, salt, iterations, dklen, dk var )
Derives a key of "dklen" bytes using PBKDF2 from PKCS #5.
Returns 1 on success or 0 on error.
  • digestname = The digest algorithm to use. May be any of the digests supported by the installed OpenSSL version.
  • password = The password from which a key is to be derived.
  • salt = Random data of any length that is used to salt the derivation. RFC 2898 recommends a minimum salt length of 8 bytes.
  • iterations = The number of iterations to perform. RFC 2898 recommends at least 1000 iterations.
  • dklen = The desired output length of the derived key. May be any positive value.
  • dk = [output] Receives the derived key. The output is in raw binary.
crypto_rand_bytes
crypto_rand_bytes( n )
Generates n random bytes.
Returns a string of bytes
  • n = the number of bytes
crypto_rand_set_rand_engine
crypto_rand_set_rand_engine( engine )
Specify the random number generating engine to use.
Return value: 1 on success, 0 on failure.
  • engine = Name of the random number generator engine to use.
crypto_sha1
crypto_sha1( buffer var, format, result var )
Returns an SHA1 hash of buffer. Secure Hash Algorithm
Returns 1 on success, 0 on failure. (including OpenSSL not being available)
  • buffer = value to hash by reference
  • output_format = 'hex' or 'binary'. Anything else will result in binary output.
  • output = returned sha1 hash value.
crypto_sha256
crypto_sha256( buffer var, format, result var )
Returns an SHA256 hash of buffer. Secure Hash Algorithm. May not be available on platforms running versions of OpenSSL Older than v0.9.8.
Returns 1 on success, 0 on failure. (including OpenSSL not being available)
  • buffer = value to hash by reference
  • output_format = 'hex' or 'binary'. Anything else will result in binary output.
  • output = returned sha1 hash value.
crypto_xor
crypto_xor( buffer var, dest var )
Efficiently performs a byte-by-byte XOR of buffer and dest, storing the resulting data in "dest". If "buffer" is longer than "dest", any extra bytes are ignored.
Returns nothing.
  • buffer = the data that will be processed.
  • dest = the data that will processed against buffer and will contain the results.
decodeattribute
decodeattribute( attribute )
Returns a copy of string (which is usually a URL) converted from URL-encoded format to ordinary text. This function is the opposite of encodeattribute.
decodeentities
decodeentities( string )
Returns a copy of string in which all HTML entities have been converted to their plain text equivalents (for example, & is converted to &). This function is the opposite of encodeentities.
dir
dir( path, location, entries var )
Reads a directory list in path.
Returns the number of files found or 0 (zero) if none are found. The parameter entries returns an array of file names found.
  • path = The path to a directory relative to the location
  • location = "data" or "script"
  • entries = array of resultant file names
encodeattribute
encodeattribute( attribute )
Returns a copy of string (which is usually a URI or part of an URI ) in URI-encoded format. Special characters such as space, tilde (~), and the plus sign are converted to hexadecimal %nn format. This function is the opposite of decodeattribute.
A URI encoded string
encodeentities
encodeentities( string )
Returns a copy of string in which all characters have been converted to their HTML entity equivalents, where applicable (for example, & is converted to "&"). This function is the opposite of decodeentities.
encodejavascriptstring
encodejavascriptstring( string )
Encodes "string" in a format suitable for use inside a JavaScript quoted string declaration, honoring the current character set.
Returns the encoded string.
  • string = the string that will be encoded.
exp
exp( number )
Returns the constant e (approximately 2.71828) Raised to the power number.
fchmod
fchmod( path, mode )
Changes a files or directory permissions.
Returns 1 if sucessful, 0 if fails
  • path = fully qualified path to the file
  • mode_number = ( nnnn decimal number) or '0nnnn' (octal string)
fcopy
fcopy( source, destination )
Copies a file in the data directory.
Returns 1 if sucessful, 0 if fails
  • source = source file fully qualified path
  • destination = destination file fully qualified path
fdelete
fdelete( path )
Deletes a file in the data directory. See sdelete()
Returns 1 if sucessful, 0 if fails
  • path = fully qualified path of the file to delete
fexists
fexists( path )
Tests if the file named in path exists in the data directory.
Returns 1 if the file exsists else 0.
  • path = the fully qualified path to the file
file_append
file_append( path, location, outputdata var )
Appends data to the end of the file in path.
Returns length of outputdata or -1 on error. file_append() will not create a file, but return -1 if the file does not exist.
  • path = fully qualified path to the file
  • location = location of the output file - 'data' or 'script'
  • outputdata = string variable containing the data to append
file_create
file_create( path, location, outputdata var )
Creates and appends data to the file in path.
Returns length of outputdata or -1 on error. file_create() will not append to an existing file, but return -1 if the file exists.
  • path = fully qualified path to the file
  • location = location of the output file - 'data' or 'script'
  • outputdata = string variable containing the data to append
file_read
file_read( path, location, inputdata var )
Reads a file.
Returns length of inputdata or -1 on error or file does not exist.
  • path = fully qualified path to the file
  • location = location of the input file - 'data' or 'script'
  • inputdata = string variable containing the data read
file_read_bytes
file_read_bytes( path, location, offset, length, data )
Reads a portion of the file specified by "path" and "location" into "data". Returns the number of bytes read, which may be less than "length", if an attempt was made to read past the end of the file, or -1 on error.
Returns the number of bytes read from the file. The file data is returned in "data".
  • path = The name or filepath of the file to open relative to the directory specified by "location"
  • location = One of "script" or "data"
  • offset = The zero-based offset at which to begin reading
  • length = The number of bytes to read. If < 0, the entire file after "offset" is read.
  • data = The variable in which to store the file data
file_touch
file_touch( file, location )
Updates the modification time of the specified file.
Return value: 0 on success, -1 on failure.
  • file = File name.
  • location = File location. "script" or "data", defaulting to "data" if any other value.
fisdir
fisdir( path )
Tests if the file named in path is a directory.
Returns 1 if the path is a directory else 0.
  • path = the fully qualified path to the directory
floor
floor( number )
Returns the largest integer less than or equal to number
fmkdir
fmkdir( path )
Creates a directory specified by path in the data directory.
Returns 1 if sucessful, 0 if fails
  • path = the fully qualified path to the directory
fmod
fmod( x, y )
Returns the remainder of number1/number2; number1, number2, and the result are all floating point numbers.
fmode
fmode( path )
Returns the permissions mode of path in the data directory.
Returns the permissions mode or -1 if the file does not exist
  • path = the fully qualified path to the file or directory
frename
frename( source, destination )
Rename source file to destination file. Can rename or move a file in the data directory.
Returns 1 if sucessful, 0 if fails
  • source = source file fully qualified path
  • destination = destination file fully qualified path
fscopy
fscopy( data_source,script_destination )
Copies a file from data directory to the scripts directory.
Returns 1 if sucessful, 0 if fails
  • data_source = source file fully qualified path
  • scripts_destination = destination file fully qualified path
fsize
fsize( path )
Get the size of a file in the data directory
Returns the file size in bytes or -1 if the file does not exist.
  • path = the fully qualified path to the file
fsrename
fsrename( source, destination )
Rename data directory source file to script directory destination file. Can rename or move a file.
Returns 1 if sucessful, 0 if fails
  • source = source file fully qualified path
  • destination = destination file fully qualified path
fssymlink
fssymlink( source, destination )
This function creates a symbolic link from a file in the data directory to the scripts directory (Available on UNIX file systems only)
Returns 1 if sucessful, 0 if fails
  • source = source file fully qualified path in the data directory
  • destination = destination file fully qualified path in the scripts directory
fsymlink
fsymlink( source, destination )
(Unix only) Creates a symbolic link to the file in the data directory.
Returns 1 if sucessful, 0 if fails
  • source = source file fully qualified path
  • destination = destination file fully qualified path
ftime
ftime( path )
Gets the last modified time for the file in data directory.
Returns time_t since a file in the was last modified or -1 if the file does not exist.
  • path = the fully qualified path to the file
gdClearLastError
gdClearLastError()
gdImageAABlend
gdImageAABlend( im )
gdImageAlpha
gdImageAlpha( im, c )
gdImageAlphaBlending
gdImageAlphaBlending( im, alphaBlendingArg )
gdImageArc
gdImageArc( im, cx, cy, w, h, s, e, color )
gdImageBlue
gdImageBlue( im, c )
gdImageBoundsSafe
gdImageBoundsSafe( im, x, y )
gdImageColorAllocate
gdImageColorAllocate( im, r, g, b )
gdImageColorAllocateAlpha
gdImageColorAllocateAlpha( im, r, g, b, a )
gdImageColorClosest
gdImageColorClosest( im, r, g, b )
gdImageColorClosestAlpha
gdImageColorClosestAlpha( im, r, g, b, a )
gdImageColorClosestHWB
gdImageColorClosestHWB( im, r, g, b )
gdImageColorDeallocate
gdImageColorDeallocate( im, color )
gdImageColorExact
gdImageColorExact( im, r, g, b )
gdImageColorExactAlpha
gdImageColorExactAlpha( im, r, g, b, a )
gdImageColorResolve
gdImageColorResolve( im, r, g, b )
gdImageColorResolveAlpha
gdImageColorResolveAlpha( im, r, g, b, a )
gdImageColorsTotal
gdImageColorsTotal( im )
gdImageColorTransparent
gdImageColorTransparent( im, color )
gdImageCompare
gdImageCompare( im1, im2 )
gdImageCopy
gdImageCopy( dst, src, dstX, dstY, srcX, srcY, w, h )
gdImageCopyMerge
gdImageCopyMerge( dst, src, dstX, dstY, srcX, srcY, w, h, pct )
gdImageCopyMergeGray
gdImageCopyMergeGray( dst, src, dstX, dstY, srcX, srcY, w, h, pct )
gdImageCopyResampled
gdImageCopyResampled( dst, src, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH )
gdImageCopyResized
gdImageCopyResized( dst, src, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH )
gdImageCopyRotated
gdImageCopyRotated( dst, src, dstX, dstY, srcX, srcY, srcWidth, srcHeight, angle )
gdImageCreate
gdImageCreate( sx, sy )
gdImageCreateFromGd
gdImageCreateFromGd( filename, location )
gdImageCreateFromGd2
gdImageCreateFromGd2( filename, location )
gdImageCreateFromGd2Mem
gdImageCreateFromGd2Mem( data var )
gdImageCreateFromGd2Part
gdImageCreateFromGd2Part( filename, location, srcx, srcy, w, h )
gdImageCreateFromGd2PartMem
gdImageCreateFromGd2PartMem( data var, srcx, srcy, w, h )
gdImageCreateFromGdMem
gdImageCreateFromGdMem( data var )
gdImageCreateFromGif
gdImageCreateFromGif( filename, location )
gdImageCreateFromGifMem
gdImageCreateFromGifMem( data var )
gdImageCreateFromJpeg
gdImageCreateFromJpeg( filename, location )
gdImageCreateFromJpegMem
gdImageCreateFromJpegMem( data var )
gdImageCreateFromPng
gdImageCreateFromPng( filename, location )
gdImageCreateFromPngMem
gdImageCreateFromPngMem( data var )
gdImageCreateFromWBMP
gdImageCreateFromWBMP( filename, location )
gdImageCreateFromWBMPMem
gdImageCreateFromWBMPMem( data var )
gdImageCreatePaletteFromTrueColor
gdImageCreatePaletteFromTrueColor( im, ditherFlag, colorsWanted )
gdImageCreateTrueColor
gdImageCreateTrueColor( sx, sy )
gdImageDashedLine
gdImageDashedLine( im, x1, y1, x2, y2, color )
gdImageDestroy
gdImageDestroy( im )
gdImageEllipse
gdImageEllipse( im, cx, cy, w, h, color )
gdImageFill
gdImageFill( im, x, y, color )
gdImageFilledArc
gdImageFilledArc( im, cx, cy, w, h, s, e, color, style )
gdImageFilledEllipse
gdImageFilledEllipse( im, cx, cy, w, h, color )
gdImageFilledPolygon
gdImageFilledPolygon( im, points var, n, color )
gdImageFilledRectangle
gdImageFilledRectangle( im, x1, y1, x2, y2, color )
gdImageFillToBorder
gdImageFillToBorder( im, x, y, border, color )
gdImageGetClip
gdImageGetClip( im, x1P var, y1P var, x2P var, y2P var )
gdImageGetInterlaced
gdImageGetInterlaced( im )
gdImageGetPixel
gdImageGetPixel( im, x, y )
gdImageGetTransparent
gdImageGetTransparent( im )
gdImageGetTrueColorPixel
gdImageGetTrueColorPixel( im, x, y )
gdImageGif
gdImageGif( im, filename, location )
gdImageGifAnimAdd
gdImageGifAnimAdd( im, out, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm )
gdImageGifAnimAddMem
gdImageGifAnimAddMem( im, ctx, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm )
gdImageGifAnimAddOutput
gdImageGifAnimAddOutput( im, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm )
gdImageGifAnimBegin
gdImageGifAnimBegin( im, filename, location, GlobalCM, Loops )
gdImageGifAnimBeginMem
gdImageGifAnimBeginMem( im, GlobalCM, Loops )
gdImageGifAnimBeginOutput
gdImageGifAnimBeginOutput( im, GlobalCM, Loops )
gdImageGifAnimEnd
gdImageGifAnimEnd( out )
gdImageGifAnimEndMem
gdImageGifAnimEndMem( ctx, output var )
gdImageGifAnimEndOutput
gdImageGifAnimEndOutput()
gdImageGifMem
gdImageGifMem( im, output var )
gdImageGifOutput
gdImageGifOutput( im )
gdImageGreen
gdImageGreen( im, c )
gdImageInterlace
gdImageInterlace( im, interlaceArg )
gdImageJpeg
gdImageJpeg( im, filename, location, quality )
gdImageJpegMem
gdImageJpegMem( im, output var, quality )
gdImageJpegOutput
gdImageJpegOutput( im, quality )
gdImageLine
gdImageLine( im, x1, y1, x2, y2, color )
gdImageOpenPolygon
gdImageOpenPolygon( im, points var, n, color )
gdImagePaletteCopy
gdImagePaletteCopy( dst, src )
gdImagePalettePixel
gdImagePalettePixel( im, x, y )
gdImagePng
gdImagePng( im, filename, location )
gdImagePngMem
gdImagePngMem( im, output var )
gdImagePngOutput
gdImagePngOutput( im )
gdImagePolygon
gdImagePolygon( im, points var, n, color )
gdImageRectangle
gdImageRectangle( im, x1, y1, x2, y2, color )
gdImageRed
gdImageRed( im, c )
gdImageSaveAlpha
gdImageSaveAlpha( im, saveAlphaArg )
gdImageSetAntiAliased
gdImageSetAntiAliased( im, c )
gdImageSetAntiAliasedDontBlend
gdImageSetAntiAliasedDontBlend( im, color, dont_blend )
gdImageSetBrush
gdImageSetBrush( im, brush )
gdImageSetClip
gdImageSetClip( im, x1, y1, x2, y2 )
gdImageSetPixel
gdImageSetPixel( im, x, y, color )
gdImageSetStyle
gdImageSetStyle( im, style var, n )
gdImageSetThickness
gdImageSetThickness( im, thickness )
gdImageSetTile
gdImageSetTile( im, tile )
gdImageSharpen
gdImageSharpen( im, pct )
gdImageSquareToCircle
gdImageSquareToCircle( im, radius )
gdImageStringFT
gdImageStringFT( im, brect var, fg, fontlist, ptsize, angle, x, y, string )
This will append a string of text to an image.
Returns an error message
gdImageStringFTCircle
gdImageStringFTCircle(
    im, cx, cy, radius, textRadius, fillPortion, font, points, top, bottom, fgcolor )
gdImageSX
gdImageSX( im )
gdImageSY
gdImageSY( im )
gdImageTrueColor
gdImageTrueColor( im )
gdImageTrueColorPixel
gdImageTrueColorPixel( im, x, y )
gdImageTrueColorToPalette
gdImageTrueColorToPalette( im, ditherFlag, colorsWanted )
gdImageWBMP
gdImageWBMP( im, fg, filename, location )
gdImageWBMPMem
gdImageWBMPMem( im, fg, output var )
gdImageWBMPOutput
gdImageWBMPOutput( im, fg )
gdLastError
gdLastError()
gdTrueColor
gdTrueColor( r, g, b )
gdTrueColorAlpha
gdTrueColorAlpha( r, g, b, a )
gettoken
gettoken( delimited_string, characters, position_num )
Returns the nth number token (i.e. substring) of a delimited_string using characters as token separators. A null string is returned if there is no nth token. Common delimiter characters are comma, tab, linefeeds, pipe but are not limited to these.
Returns the position_num token (i.e. substring) of a delimited_string delimited by characters.
  • delimited_string = A string delimited by a character or characters
  • characters = the delimiter character or characters
  • position_num = the position of the substring you want to return
glosub
glosub( target_string, search, replace )
Global substitution returns a copy of string in which all instances of string search have been replaced by string replace. (Note: to represent a backslash () in replace, use '\\').
Returns string where all instances of search have been replaced.
  • target_string = the target string
  • search = the sub-string that will be search ed for
  • replace = the replacement string
glosub_array
glosub_array( string, search_array, replace_array )
Works like glosub(), but search_array and replace_array are iterated through, each value in search_array found in the string is replaced by the corresponding value in replace_array
Return Value: string is returned with all found values replaced.
  • string = the target
  • search_array = an array of strings that will be searched for
  • replace_array = an array of the replacement strings
indexof
indexof( search_string, target_string var, start_number )
Returns the position of the first occurrence of search_string within the target_string beginning at the start_number position. The search is CASE SENSITIVE sensitive. If not found, the functions return 0. The offset parameter and returned string offset are 1-based. For speed, target_string is passed by reference .
Returns the 1 based offset_number of search_string within the target_string. The search is case sensitive.
  • search_string = the string that will be searched for
  • target_string = the string that will be searched
  • start_number = the 1 based starting offset withing the target_string where the search will begin
indexofi
indexofi( search_string, target_string var, start_number )
Returns the position of the first occurrence of search_string within the target_string beginning at the start_number position. The search is CASE IN-SENSITIVE. If not found, the functions return 0. The offset parameter and returned string offset are 1-based. For speed, target_string is passed by reference
Returns the 1 based offset_number of search_string within the target_string. The search is case in-sensitive.
  • search_string = the string that will be searched for
  • target_string = the string that will be searched
  • start_number = the 1 based starting offset withing the target_string where the search will begin
indexofl
indexofl( needle, haystack var, offset )
Search from the end of the haystack for needle, starting at the offset position.
Return value: Index of found value, or 0 if not found.
  • needle var = Value to search for.
  • haystack var = Text to search.
  • offset = integer offset to start at.
indexofli
indexofli( needle, haystack var, offset )
Search without regard to case from the end of the haystack for needle, starting at the offset position.
Return value: Index of found value, or 0 if not found.
  • needle var = Value to search for.
  • haystack var = Text to search.
  • offset = integer offset to start at.
int
int( number )
Returns integer portion of number (removes the decimal and any digits to the right of it)
isalnum
isalnum( string )
Test if all characters are either alphabetic or digits
Returns 1 if true, 0 if false
  • string = the characters tested
isalpha
isalpha( string )
Test if all characters are alphabetic.
Returns 1 if true, 0 if false
  • string = the characters tested
isascii
isascii( string )
Test if all characters are ASCII characters (those with decimal value between 0 and 127).
Returns 1 if true, 0 if false
  • string = the characters tested
iscntrl
iscntrl( string )
Test if all characters are control characters (those with decimal value between 0 and 31, or 127).
Returns 1 if true, 0 if false
  • string = the characters tested
isdigit
isdigit( string )
Test if all characters are digits in the range 0-9.
Returns 1 if true, 0 if false
  • string = the characters tested
isgraph
isgraph( string )
Test if all characters are graphic (see isprint) characters (those with decimal value between 33 and 127).
Returns 1 if true, 0 if false
  • string = the characters tested
islower
islower( string )
Test if all characters are lowercase letters,
Returns 1 if true, 0 if false
  • string = the characters tested
isprint
isprint( string )
Test if all characters are printable (same as graphic characters, with the addition of the space character).
Returns 1 if true, 0 if false
  • string = the characters tested
ispunct
ispunct( string )
Test if all characters are whitespace (space, tab, vertical tab, newline, form feed) characters.
Returns 1 if true, 0 if false
  • string = the characters tested
isspace
isspace( string )
Test if all characters are whitespace (space, tab, vertical tab, newline, form feed) characters.
Returns 1 if true, 0 if false
  • string = the characters tested
isupper
isupper( string )
Test if all characters are uppercase letters.
Returns 1 if true, 0 if false
  • string = the characters tested
isxdigit
isxdigit( string )
Test if all characters are hexadecimal digits (a-f, A-F, 0-9).
Returns 1 if true, 0 if false
  • string = the characters tested
keyword_extract
keyword_extract( string, keywords var )
Given a string, will extract keywords from it. Skipping SGML tags and stemming words (e.g., "running" becomes "run", but "bring" is not changed), the unique list of keywords are placed in the keywords as an array. Also, some common english words (the articles, "for" "are", etc.) are removed. Note that there are some words may stem unexpectedly (e.g., "has" transforms to "ha").
Populates the keywords array and returns number of elements.
keyword_extract_merge
keyword_extract_merge( string, weight )
Extracts keywords as described in keyword_extract, but inserts them into a persistent array initialized by keyword_extract_merge_init. The weight value passed in is associated with the results from the current string being analyzed. Return null.
Returns null.
keyword_extract_merge_init
keyword_extract_merge_init()
Initializes persistent storage for a multiple calls to keyword_merge_extract. Note that this persistent storage is usable for multiple calls within a running Miva Script program, and is deleted by the VM at the end of program execution.
Returns null.
keyword_extract_merge_results
keyword_extract_merge_results( keywords var )
Returns results from one or more keyword_extract_merge calls, storing them as an aggregate in "keywords".
Returns null.
keyword_in
keyword_in( keywords_array var, search_string )
Performs a keyword_extract() on the string parameter, and determines if the value in the keywords parameter is contained in the keyword list, and returns a boolean 1 or 0 to signify that the keyword is or is not in the string. If the keywords parameter is an array of strings, checks each value in the array, and returns an array of booleans specifying whether the array element is or is not in the string.
If keywords is an array, returns an array of booleans specifying if a given keyword element is in the keyword list. -- If keywords is a string, returns a boolean specifying if the given keyword is in the keyword list.
len
len( string )
Returns the number of characters in string.
The length of string.
  • string = a literal string value embedded in single quotes or an expression that evaluates as a string.
len_var
len_var( string var )
Returns the number of characters in string. This function is identical to len() but its parameter is passed by reference, improving performance when dealing with large strings.
the length of the string
  • string = a literal string value embedded in single quotes or an expression that evaluates as a string.
log
log( number )
Returns the natural logarithm (base e, approximately 2.71828) of number.
log10
log10( number )
Returns the base 10 logarithm of number
ltrim
ltrim( string )
Returns a copy of string with all space characters removed from the left end.
makesessionid
makesessionid()
Returns a 128-bit unique ID.
miva_array_binarysearch
miva_array_binarysearch( key, array var, callback, data var )
Performs a binary search for "key" in "array". "array" must have been previously sorted.
Returns the index of "key" in "array" or 0 if no match was found.
  • key = The value that will be searched for.
  • array var = The array that will be searched.
  • callback = The name of a callback function. See below.
  • data var = Optional data that is passed through to the callback function
miva_array_clear
miva_array_clear( array var, start, count )
Removes "count" elements from "array", starting at position "start". The elements are removed from the array, but the array is not collapsed.
Returns the number of elements remaining in the array.
  • array = The array that will be altered.
  • start = the starting index numbert
  • count = the number of elements that will be cleared
miva_array_collapse
miva_array_collapse( aggregate var )
Collapses the array_variable making the indices sequential starting at 1. Returns the number of elements in the array.
miva_array_copy
miva_array_copy( source var, sstart, scount, dest var, dpos )
Copies "scount" elements from "source" into "dest", starting with "sstart" and placing the elements at "dpos". Existing elements in "dest" are overwritten.
Returns the number of elements in the "dest" array after the copy.
  • source = The source array from which records will be copied
  • sstart = The source starting index
  • scount = The number of source records to copy.
  • dest = The destination array that will receive the copied records.
  • dpos = The starting index within the destination array. Overlapping elements in "dest" are overwritten.
miva_array_copy_ref
miva_array_copy_ref( source var, sstart, scount, dest var, dpos )
Copies "scount" elements from "source" into "dest", starting with "sstart" and placing the elements at "dpos". Existing elements in "dest" are overwritten.
Returns the number of elements in the "dest" array after the copy.
  • source = The source array from which records will be copied
  • sstart = The source starting index
  • scount = The number of source records to copy.
  • dest = The destination array that will receive the copied records.
  • dpos = The starting index within the destination array. Overlapping elements in "dest" are overwritten.
miva_array_delete
miva_array_delete( array var, start, count )
Removes "count" elements from "array", starting at position "start". The array is collapsed after the elements are removed.
Returns the number of elements remaining in the array.
  • array = The array that will be altered.
  • start = the starting index numbert
  • count = the number of elements that will be cleared
miva_array_deserialize
miva_array_deserialize( string )
Reverses miva_array_serialize(). Returns an aggregate array repopulated to match the original.
miva_array_elements
miva_array_elements( aggregate var )
Returns the number of elements in the array_variable that were actually used.
miva_array_filter
miva_array_filter( array var, offset, element var, filter_expression, output var )
Iterate through an array starting at a given offset, execute a filter expression against each element, and copy the member to a new output array. See also miva_array_filter_ref.
Return value: Count of output array elements.
  • array var = Source array of structures.
  • offset = index in the array to start filtering from.
  • element var = Name of a variable to reference in the filter expression.
  • filter_expression = Text of an expression to execute based on the individual array element.
  • output var = Output array of all structures that tested true in the filter expression.
miva_array_filter_ref
miva_array_filter_ref( array var, offset, element var, filter_expression, output var )
Iterate through an array starting at a given offset, execute a filter expression against each element, and create a new member with references to the members in the output array. See also miva_array_filter.
Return value: Count of output array elements.
  • array var = Source array of structures.
  • offset = index in the array to start filtering from.
  • element var = Name of a variable to reference in the filter expression.
  • filter_expression = Text of an expression to execute based on the individual array element.
  • output var = Output array of all structures that tested true in the filter expression.
miva_array_find
miva_array_find( needle, haystack var, offset )
Performs a sequential search for "needle" in array "haystack", starting at "offset". Comparison is equivalent to the EQ operator. (i.e. looks for an exact match)
Returns the index of "needle" in "haystack" or 0 if the element was not found.
  • needle = value to search for
  • haystack var = the array to search
  • offset = the starting index position
miva_array_insert
miva_array_insert( array var, element, pos )
Inserts single element "element" into "array" at position "pos". If "pos" = -1, the element is inserted at the end of "array".
Returns the number of elements in "array" after the insertion.
  • array = The array tro which the records will be inserted
  • element = the record that will be inserted
  • pos = the index where the element will be inserted.
miva_array_insert_ref
miva_array_insert_ref( array var, element var, pos )
Inserts single element "element" into "array" at position "pos".
Returns the number of elements in "array" after the insertion.
  • array = The array tro which the records will be inserted
  • element = the record that will be inserted
  • pos = the index where the element will be inserted.
miva_array_insert_var
miva_array_insert_var( array var, element var, pos )
Inserts single element "element" into "array" at position "pos".
Returns the number of elements in "array" after the insertion.
  • array = The array tro which the records will be inserted
  • element = the record that will be inserted
  • pos = the index where the element will be inserted.
miva_array_max
miva_array_max( aggregate var )
Return the maximum array_variable index used.
miva_array_merge
miva_array_merge( source var, sstart, scount, dest var, dpos )
Copies "scount" elements from "source" into "dest", starting with "sstart" and inserting the elements at "dpos". Existing elements in "dest" past "dpos" are pushed forward by "scount" elements.
Returns the number of elements in the "dest" array after the merge.
  • source = The source array from which records will be copied
  • sstart = The source starting index
  • scount = The number of source records to copy.
  • dest = The destination array that will receive the copied records.
  • dpos = The starting index within the destination array. Existing elements in "dest" past "dpos" are pushed forward by "scount" elements.
miva_array_merge_ref
miva_array_merge_ref( source var, sstart, scount, dest var, dpos )
Copies "scount" elements from "source" into "dest", starting with "sstart" and inserting the elements at "dpos". Existing elements in "dest" past "dpos" are pushed forward by "scount" elements.
Returns the number of elements in the "dest" array after the merge.
  • source = The source array from which records will be copied
  • sstart = The source starting index
  • scount = The number of source records to copy.
  • dest = The destination array that will receive the copied records.
  • dpos = The starting index within the destination array. Existing elements in "dest" past "dpos" are pushed forward by "scount" elements.
miva_array_min
miva_array_min( aggregate var )
Return the minumum array_variable index used.
miva_array_next
miva_array_next( aggregate var, index )
miva_array_pop
miva_array_pop( array var )
Removes and returns the last element of "array".
Returns the number of elements remaining in "array".
  • array = the array where the record will be remove.
miva_array_pop_ref
miva_array_pop_ref( array var, element var )
Makes "element" a reference to the last element of "array", then removes it from the array.
Returns the number of elements remaining in "array".
  • array = the array where the record will be remove.
miva_array_previous
miva_array_previous( aggregate var, index )
miva_array_search
miva_array_search( array var, offset, element var, filter_expr )
Performs an sequential search in "array", starting at "offset". Comparison is made by evaluating "filter_expr" for each element. This allows you to specify the comparison type.
Returns the index of the first element in "array" for which filter_expr evaluated as true, or 0 if no elements met this condition.
  • array var = the array that will be searched
  • offset = the starting index for the search
  • element var = a variable name used to reference individual array records. See Example 1
  • filter_expr = an expression similar to the EXPR attribute to MvFILTER. See Example 2
miva_array_serialize
miva_array_serialize( aggregate var )
Returns a string representation of the array and any subarrays. Can be used to store an entire array in a database for later retreival.
miva_array_shift
miva_array_shift( array var )
Removes and returns the first element of "array".
Returns the first element of "array".
  • array = the array where the record will be remove.
miva_array_shift_ref
miva_array_shift_ref( array var, element var )
Makes "element" a reference to the first element of "array", then removes it from the array.
Returns the number of elements remaining in "array".
  • array = the array where the record will be remove
  • element = a reference to the element that was removed.
miva_array_sort
miva_array_sort( aggregate var, callback, data var )
This function will sort an array structure
Returns the number of array elements in the aggregate array structure after sorting.
  • Aggregate: The array that will be sorted. (the aggregate will be physically altered on return)
  • Callback: The name of a user function that must exist in your program, defined as Callback(left var, right var, data var)
  • Data: Not directly used in the miva_array_sort(), the value will be passed to the Callback function.
miva_async_sleep
miva_async_sleep( until, semfile, semlocation )
Sleep until the "until" time, or the modified time on the file described by semfile and semlocation is changed.
Return Value: None
  • until = time_t (seconds since 1-JAN-1970) set in the future, the time to sleep until
  • semfile = file name to watch
  • semlocation = location of the file to watch. "script" or "data", defaulting to "data" if any other value.
miva_cdata_encode
miva_cdata_encode( text )
Create one or more CDATA tags with the provided text, splitting any data with "]]>" into two CDATA tags with "]]" at the end of one CDATA tag, and ">" as the first value of the next CDATA tag.
Return value: Text quoted within one or more CDATA tags.
  • text = String to encode
miva_closelog
miva_closelog()
Closes the connection to the log file and otherwise eliminates the effect of the last call to miva_openlog. Will cause any subsequent calls to miva_setlogmask and miva_writelog to fail until miva_openlog is called again.
Returns 1 on success, 0 on error
miva_csv_encode
miva_csv_encode( text, delimiter )
miva_element_exists
miva_element_exists( array var, index )
Tests if an element exists where: array is an array and index is index number being tested.
Returns 1 if the element found else 0
miva_getvarlist
miva_getvarlist( scope )
Returns a comma-separated list of the names of all currently defined variables where: scope = the string literal "l", "g", "s" (i.e. local, global, system)
miva_hex_decode
miva_hex_decode( data )
Convert "data" to hexadecimal notation.
returns the resulting decoded data
  • data = the hex data to decode.
miva_hex_encode
miva_hex_encode( data )
Convert "data" to hexadecimal notation.
returns the resulting encoded data.
  • data = the value to encode.
miva_html_strip
miva_html_strip( text, allowed_tags )
Removes HTML tags from a given string.
Return value: Text string with all HTML tags except those listed in allowed_tags removed.
  • text = String to remove HTML tags from.
  • allowed_tags = A comma-separated list of tags that will not be stripped from the string.
miva_ieee754_normalize
miva_ieee754_normalize( significant_digits, value )
Normalize the value to IEEE 754 specifications, to the given number of significant digits.<br>
Return value: The normalized value to the specified significant digits
  • significant_digits = Number of digits to normalize the value to.
  • value = Floating point value to normalize.
miva_json_decode
miva_json_decode( data, output var )
Decodes a block of JSON data in "data", returning the parsed aggregate value in "output".
Returns 1 on success, 0 on error.
  • data = The block of JSON encoded data that will be decoded output var = The function assigns the parsed aggregate to "output" as a structured array.
miva_json_decode_last_error
miva_json_decode_last_error()
Returns a text description of the most recent parsing error encountered by miva_json_decode()
Returns a text description of the most recent parsing error.
miva_lockfile
miva_lockfile( path, location )
Creates and locks a lockfile. Similar to the behavior of MvLOCKFILE without the closing /MvLOCKFILE behavior. It also creates the exact filename, rather than appending ".lck" to the filename as MvLOCKFILE does.
Returns 1 if sucessful, -1 if fails
  • path = fully qualified path to the file
  • location = location of the file - 'data' or 'script'
  • Use fdelete() or sdelete() to delete the lockfile.
miva_member_exists
miva_member_exists( structure var, member )
Tests if a member exists where: "structure" is a data structure and "member" is the name of a structure member being tested. Returns 0 or 1.
Returns 1 if found else returns 0
  • structure: A data structure or structured array that is tested. It is passed by reference to the function.
  • member: The literal member name or a variable that evaluates as the member name.
miva_openlog
miva_openlog( ident, logopt, facility )
Opens a connection to the log file and sets default behavior for all subsequent miva_writelog calls.
Returns 1 on success, 0 on error
  • ident = a string that will be prepended to all subsequent log messages. May be the empty string.
  • logopt = a string containing a list of options. Each option may be any of the words listed below. Commas and/or spaces separate the options. An empty string is permitted.
  • facility = The default facility code for subsequent messages. May be any one of the words listed below.
miva_output_flush
miva_output_flush()
Writes the HTTP headers and any other output to the browser. Subsequent calls will write the output, but not the headers.
miva_output_header
miva_output_header( header, value )
Sets an HTTP header name-value pair.
miva_setdefaultdatabase
miva_setdefaultdatabase( database )
This function takes a string as a parameter which specifies the type of database to which the miva_defaultdatabase system variable is set.
miva_setdefaultlanguage
miva_setdefaultlanguage( language )
miva_setlanguage
miva_setlanguage( language )
miva_setlogmask
miva_setlogmask( maskpri )
Causes all subsequent calls to miva_writelog to be ignored unless they specify a priority that is included in the maskpri argument. Will return failure unless the miva log is open.
Returns 1 on success, 0 on error
  • maskpri = a string containing a list of priorities. Each priority may be any of the words listed below. Commas and/or spaces separate the priorities. An empty string is permitted but means that all subsequent miva_writelog calls will be ignored.
miva_setprocessname
miva_setprocessname( name )
Set the process name (where possible) and alters the s.process_name variable.
Return value: None.
  • name = Text to set the process name to.
miva_sleep
miva_sleep( msecs )
Delays the running application for msecs milliseconds or until the global timeout expires, whichever is shorter.
Return Value: None
  • msecs = the number of milliseconds to delay
miva_splitstring
miva_splitstring( string, sep, output var, flags )
Splits a string into chunks in an array, using the separator parameter as the point to split the string. Returns the number of elements in the output array.
Returns: The number of elements in the output array.
  • string = The input string
  • sep = A single character that will be used to split the string into multiple elements (for example a comma or space)
  • output var - The array of elements returned
  • flags - A comma separated list of any of the following keywords
    trim : removes extra space around the left and right sides of all elements
    ltrim : removes extra space around the left side of all elements
    rtrim : removes extra space around the right side of all elements
    lower : converts all elements to lowercase
    upper : converts all elements to uppercase
    insensitive : searches for the sep input parameter using a case-insensitive search
miva_struct_members
miva_struct_members( aggregate var, members var )
miva_struct_merge
miva_struct_merge( source var, dest var )
Copy the structure members from source into dest, if the member does not exist in dest. See also miva_struct_merge_ref.
Return value: 0 on success, -1 on failure.
  • source - Structure to copy into dest.
  • dest - Destination structure.
miva_struct_merge_ref
miva_struct_merge_ref( source var, dest var )
Make references of the structure members from source in dest, if the member does not exist in dest. Similar to miva_struct_merge, but makes references into original structure rather than copies.
Return value: None.
  • source - Structure to copy into dest.
  • dest - Destination structure.
miva_template_compile
miva_template_compile( signat, source var, sourceitems var, target, errors var )
Compiles the contents of a string into a page template file.
Returns 1 if compilation succeeds, 0 if error occured.
  • signat = Any text. The md5 hash value of this text will bestored in the MVC file.
  • source = The source to compile into a template file.
  • sourceitems = array of valid item names.The compiler will return an error if an mvt:item tag has a "name" attribute that is not in this list.
  • target = The name of the file (relative to the script directory) to put the .mvc file.
  • errors = If the function returns 0, this will contain error text.
miva_template_compile_dump
miva_template_compile_dump( source var, errors var )
miva_template_compile_itemlist
miva_template_compile_itemlist( signat, source var, sourceitems var, target, errors var )
miva_variable_value
miva_variable_value( string )
Returns the value of a variable where expression is the literal name of the variable.
miva_writelog
miva_writelog( priority, message )
Writes a message to the log with the specified priority. Will return failure unless the miva log is open.
Returns 1 on success, 0 on error
  • priority = a string containing a list of words. These words may be either a facility code (see miva_openlog) or a priority code (see miva_setlogmask). Commas and/or spaces separate the words. The facility may be omitted in which case the default will be assumed (see miva_openlog). If the priority is omitted or has been disabled via a call to miva_setlogmask, then the miva_writelog call will be ignored.
  • message = a string that will be written to the log.
mktime_t
mktime_t( year, month, dayofmonth, hours, minutes, seconds, timezone )
Returns the s.time_t value for the time specified. time_zone can be the keyword 'local'
padl
padl( string, length, character )
Returns a string length characters long, consisting of string padded on the left with as many instances of padcharacter as are needed to make up the full length.
padr
padr( string, length, character )
Returns a string length characters long, consisting of string padded on the right with as many instances of padcharacter as are needed to make up the full length.
power
power( number, matissa )
Raises number to a a power (for example, power(12,2)=144)
random
random( max )
Returns a random number less than or equal to maximum
rnd
rnd( value, precision )
Works like the ROUND operator, rounding number up or down to number_of_places after the decimal
rsa_free
rsa_free( rsa var )
Frees memory associated with a previously loaded RSA keypair.
Returns 1 on success, 0 on error.
  • rsa = a handle returned by one of the rsa_load_xxx functions
rsa_generate_keypair
rsa_generate_keypair( pubkey_file, privkey_file, bits, e, passphrase )
Generates an RSA keypair, saving the public key in pubkey_file, the private key in privkey_file, and encrypting the private key with passphrase.
Returns 1 on success, 0 on error.
  • pubkey_file = The name of the file in which the generated public key is stored
  • privkey_file = The name of the file in which the generated private key is stored
  • bits = The RSA modulus size, in bits
  • e = The public key exponent. Must be an odd number, typically 3, 17 or 65537
  • passphrase = The passphrase used to encrypt the private key
rsa_generate_keypair_mem
rsa_generate_keypair_mem( pubkey var, privkey var, bits, e, passphrase )
Generates an RSA keypair, returning the public and private keys in variables, and encrypting the private key with passphrase.
Returns 1 on success, 0 on error.
  • pubkey = The variable which receives the generated public key
  • privkey = The variable which receives the generated private key
  • bits = The RSA modulus size, in bits
  • e = The public key exponent. Must be an odd number, typically 3, 17 or 65537
  • passphrase = The passphrase used to encrypt the private key
rsa_generate_keypair_mem_cipher
rsa_generate_keypair_mem_cipher( pubkey var, privkey var, bits, e, passphrase, ciphername )
Behaves identical to the legacy counterpart rsa_generate_keypair_mem() except that it allows the caller to specify the cipher used to encrypt the private key (the legacy function always uses des-ede3-cbc).
Returns 1 on success or 0 on error.
  • pubkey = The variable which receives the generated public key
  • privkey = The variable which receives the generated private key
  • bits = The RSA modulus size, in bits
  • e = The public key exponent. Must be an odd number, typically 3, 17 or 65537
  • passphrase = The passphrase used to encrypt the private key
  • ciphername = an OpenSSL cipher identifier, such as "aes-128-cbc"
rsa_load_privatekey
rsa_load_privatekey( privkey_file, rsa var, passphrase )
Load an encrypted RSA private key from a PKCS#8 file specified by privkey_file, and decrypt it using passphrase.
Returns 1 on success, 0 on error.
  • privkey_file = The name of the file containing the encrypted private key
  • rsa = A variable which receives an internal reference to the loaded RSA key
  • passphrase = The passphrase used to decrypt the private key
rsa_load_privatekey_engine
rsa_load_privatekey_engine( engine, key_id, rsa var )
Load an encryption key based on a key id.
Return value: 1 on success, 0 on failure.
  • engine = Name of the encryption engine to use.
  • key_id = identifier of the key to load
  • rsa = RSA private key associated with the engine and key ID.
rsa_load_privatekey_mem
rsa_load_privatekey_mem( privkey, rsa var, passphrase )
Loads an encrypted RSA private key from a memory buffer containing PKCS#8 data
Returns 1 on success, 0 on error.
  • privkey = The encrypted private key information in PKCS#8 format
  • rsa = A variable which receives an internal reference to the loaded RSA key
  • passphrase = The passphrase used to decrypt the private key
rsa_load_publickey
rsa_load_publickey( pubkey_file, rsa var )
Load an RSA public key from a PKCS#1 file specified by "pubkey_file".
Returns 1 on success, 0 on error.
  • pubkey_file = The name of the file containing the public key
  • rsa = A variable which receives an internal reference to the loaded RSA key
rsa_load_publickey_engine
rsa_load_publickey_engine( engine, key_id, rsa var )
Load an encryption key based on a key id.
Return value: 1 on success, 0 on failure.
  • engine = Name of the encryption engine to use.
  • key_id = identifier of the key to load
  • rsa = RSA public key associated with the engine and key ID.
rsa_load_publickey_mem
rsa_load_publickey_mem( pubkey, rsa var )
Loads an RSA public key from a memory buffer containing PKCS#1 data
Returns 1 on success, 0 on error.
  • pubkey = The public key in PKCS#1 format
  • rsa = A variable which receives an internal reference to the loaded RSA key
rsa_private_decrypt
rsa_private_decrypt( rsa, encrypted, plaintext var )
Decrypts data previously encrypted using the public key portion of an RSA keypair.
Returns 1 on success, 0 on error.
  • rsa = The internal reference to the RSA private key used for decryption
  • encrypted = The encrypted ciphertext, in raw binary format
  • plaintext = A variable which receives the decrypted plaintext
rsa_private_encrypt
rsa_private_encrypt( rsa, plaintext, encrypted var )
Encrypts data using the private key portion of an RSA keypair.
Returns 1 on success, 0 on error.
  • rsa = The internal reference to the RSA private key used for encryption
  • plaintext = The data to be encrypted
  • encrypted = A variable which receives the encrypted ciphertext in raw binary format
rsa_public_decrypt
rsa_public_decrypt( rsa, encrypted, plaintext var )
Decrypts data previously encrypted using the private key portion of an RSA keypair.
Returns 1 on success, 0 on error.
  • rsa = The internal reference to the RSA public key used for decryption
  • encrypted = The encrypted ciphertext, in raw binary format
  • plaintext = A variable which receives the decrypted plaintext
rsa_public_encrypt
rsa_public_encrypt( rsa, plaintext, encrypted var )
Encrypts data using the public key portion of an RSA keypair.
Returns 1 on success, 0 on error.
  • rsa = The internal reference to the RSA public key used for encryption
  • plaintext = The data to be encrypted
  • encrypted = A variable which receives the encrypted ciphertext in raw binary format
rsa_save_privatekey
rsa_save_privatekey( privkey_file, rsa var, passphrase )
Encrypts and writes a previously loaded RSA private key to a file in PKCS#8 format
Returns 1 on success, 0 on error.
  • privkey_file = The name of the file in which the private key is to be stored
  • rsa = The internal reference to the RSA private key to be saved
  • passphrase = The passphrase used to encrypt the private key
rsa_save_privatekey_mem
rsa_save_privatekey_mem( privkey var, rsa var, passphrase )
Encrypts a previously loaded RSA private key and stores it into a variable in PKCS#8 format
Returns 1 on success, 0 on error.
  • privkey = The variable which will receive the encrypted private key
  • rsa = The internal reference to the RSA private key to be saved
  • passphrase = The passphrase used to encrypt the private key
rsa_save_privatekey_mem_cipher
rsa_save_privatekey_mem_cipher( privkey var, rsa var, passphrase, ciphername )
Behaves identical to the legacy counterpart rsa_save_privatekey_mem() except that it allows the caller to specify the cipher used to encrypt the private key (the legacy function always uses des-ede3-cbc).
  • ciphername = an OpenSSL cipher identifier that specifies the cipher to be used. Note that OpenSSL only permits a subset of its supported ciphers to be used for RSA key encryption. For example, only CBC mode ciphers are permitted.
rsa_sign
rsa_sign( rsa, buffer, signature var )
Generates a digital signature using SHA1 and an RSA private key
Returns 1 on success, 0 on failure. Requires OpenSSL 0.9.7 or greater.
  • rsa = The internal reference to the RSA private key to be used
  • buffer = The data to be signed
  • signature = A variable which receives the signature in raw binary format
rsa_verify
rsa_verify( rsa, buffer, signature )
Verifies a digital signature previously generated by rsa_sign
Returns 1 on success, 0 on verification failure or error. Requires OpenSSL 0.9.7 or greater.
  • rsa = The internal reference to the RSA public key used for verification
  • buffer = The data for which the signature is to be verified
  • signature = The signature to verify, in raw binary format
rtrim
rtrim( string )
Returns a copy of string with all space characters removed from the right end.
schmod
schmod( path, mode )
Changes a files or directory permissions.
Returns 1 if sucessful, 0 if fails
  • path = fully qualified path to the file
  • mode_number = ( nnnn decimal number) or '0nnnn' (octal string)
scopy
scopy( source, destination )
Copies a file in the scripts directory.
Returns 1 if sucessful, 0 if fails
  • source = source file fully qualified path
  • destination = destination file fully qualified path
sdelete
sdelete( path )
Deletes a file in the scripts directory. See See fdelete()
Returns 1 if sucessful, 0 if fails
  • path = fully qualified path of the file to delete
sexists
sexists( path )
Tests if the file named in path exists in the scripts directory.
Returns 1 if the file exsists else 0.
  • path = the fully qualified path to the file.
sfcopy
sfcopy( source, destination )
Copies a file from the scripts directory to the data directory.
Returns 1 if sucessful, 0 if fails
  • scripts_source = source file fully qualified path in the scripts folder
  • data_destination = destination file fully qualified path in the data folder
sfrename
sfrename( source, destination )
Rename source file to destination file. Can rename or move a file in the scripts directory.
Returns 1 if sucessful, 0 if fails
  • source = source file fully qualified path
  • destination = destination file fully qualified path
sfsymlink
sfsymlink( source, destination )
This function creates a symbolic from a file in the scripts directory to the data directory (Available on UNIX file systems only)
Returns 1 if sucessful, 0 if fails
  • source - source file fully qualified path in the scripts directory
  • destination = destination file fully qualified path in the data directory
sin
sin( number )
Returns the sine of number. The argument should be expressed in radians.
sinh
sinh( number )
Returns the hyperbolic sine of number. The argument should be expressed in radians.
sisdir
sisdir( path )
Tests if the file named in path is a directory.
Returns 1 if the path is a directory else 0.
  • path = the fully qualified path to the directory
slugify
slugify( data )
Use this function to create friendly (human-readable) URLs. It takes characters that are forbidden in URIs and either converts them to a valid ASCII character or remove them completely. It adds a hyphen (-) in place of all space characters. For example, the product "Dodger Blue Baseball Hat!" becomes "Dodger-Blue-Baseball-Hat" which is now URI friendly.
A URL friendly string.
smkdir
smkdir( path )
Creates a directory specified by path in the scripts directory.
Returns 1 if sucessful, 0 if fails
  • path = the fully qualified path to the directory
smode
smode( path )
Returns the permissions mode of path in the scripts directory.
Returns the permissions mode or -1 if the file does not exist
  • path = the fully qualified path to the file or directory
sqrt
sqrt( number )
Returns the square root of number.
srandom
srandom( seed )
Allows a script to reseed the random number generator used by random()
srename
srename( source, destination )
Rename source file to destination file. Can rename or move a file in the scripts directory.
Returns 1 if sucessful, 0 if fails
  • source = source file fully qualified path
  • destination = destination file fully qualified path
ssize
ssize( path )
Get the size of a file in the scripts directory
Returns the file size in bytes or -1 if the file does not exist.
  • path = the fully qualified path to the file
ssymlink
ssymlink( source, destination )
(Unix only) Creates a symbolic link to the file in the scripts directory.
Returns 1 if sucessful, 0 if fails
  • source = source file fully qualified path
  • destination = destination file fully qualified path
stime
stime( path )
Gets the last modified time for the file in scripts directory.
Returns time_t since a file in the was last modified or -1 if the file does not exist.
  • path = the fully qualified path to the file
substring
substring( string, position, length )
Returns the substring of string, beginning at position start, length characters long.
substring_var
substring_var( string var, position, length )
Returns the substring of string, beginning at position start, length characters long. This function is identical to substring() but its first parameter is passed by reference, improving performance when dealing with large strings.
tan
tan( number )
Returns the tangent of number. The argument should be expressed in radians.
tanh
tanh( number )
Returns the hyperbolic tangent of number. The argument should be expressed in radians.
tar_create
tar_create( file, file_loc, dir, dir_loc, flags )
Creates a compressed Unix style tar file.
Return 1 on success 0 on failure
  • file = target output file
  • location = location of the output file - 'data' or 'script'
  • dir = source directory to create a tarball of
  • dir_loc = location of the source file - 'data' or 'script' defaulting to data
  • flags = may be an empty string or 'compress' which will cause the output .tar file to be bzip2 encoded.
tar_directory
tar_directory( file, location, desc var )
Return information about a tar file.
Number of files in output array, 0 on error
  • filepath = File name and path within the location
  • location = Either "script" or "data". Anything else defaults to "data".
  • desc (out) = An array of structures, one array element for each item in the tar file, with the following members assigned:
  • NAME: Text
tar_extract
tar_extract( file, file_loc, dir, dir_loc )
Unpacks a tar file to a specified directory.
Returns 1 on success 0 on failure
  • file = the path and file name
  • tar_location = source 'data' or 'script'
  • dir = destination directory to extract the tar file to
  • dir_location = destination 'data' or 'script'
time_t_dayofmonth
time_t_dayofmonth( timet, time_zone )
Returns the current month as a number. time_zone can be the keyword 'local'
time_t_dayofweek
time_t_dayofweek( timet, time_zone )
Returns the current day of the week as a number (Sunday=1). time_zone can be the keyword 'local'
time_t_dayofyear
time_t_dayofyear( timet, time_zone )
Returns the number of days since the beginning of the year, including today. time_zone can be the keyword 'local'
time_t_hour
time_t_hour( timet, time_zone )
Returns current hour (using a 24-hour clock). time_zone can be the keyword 'local'
time_t_min
time_t_min( timet, time_zone )
Returns the current minute in the hour. time_zone can be the keyword 'local'
time_t_month
time_t_month( timet, time_zone )
Returns the current month as a number. time_zone can be the keyword 'local'
time_t_sec
time_t_sec( timet, time_zone )
Returns the current second in the minute. time_zone can be the keyword 'local'
time_t_year
time_t_year( timet, time_zone )
Returns the current year, time_zone can be the keyword 'local'
timezone
timezone()
Returns an integer which is the number of hours behind or ahead of GMT (not accounting for Daylight Time)
tokenize
tokenize( string, variables )
Returns the string, concatenated with the value of each token contained in replacements. Replacements is an array of structures, each with a token and a value.
tolower
tolower( string )
Returns a copy of string in lower case.
toupper
toupper( string )
Returns a copy of string in upper case.
trim
trim( string )
Returns the value of string with leading and trailing spaces removed
wdownload
wdownload( url, filepath, location, callback, callbackdata var )
Downloads and stores a file from a URL. Acts as a front end to wget()
Returns -1 if fails, returns the server response code: Possible examples 200 = success, 301 = moved, 404 = not found.
  • url = file to retrieve
  • filepath = where destination file should be stored
  • location = destination 'data' or 'script'.callback_fn = the name of a callback function in current Miva Script file
  • callback_fn( size, total, data var ): a user defined user function that returns 1 to continue, 0 to abort.
  • callbackdata var = ???? Unknow please clarify
wget
wget( url, filepath, location )
Downloads and stores a file from a URL. Note: If an error occurs, the error message will be stored instead.
Returns -1 if fails, returns the server response code: Possible examples 200 = success, 301 = moved, 404 = not found.
  • url = file to retrieve
  • filepath = where destination file should be stored
  • location = destination 'data' or 'script'.
x509_create
x509_create( cert, x509 var )
Create an X509 Certificate from the PEM format data in "cert" where cert = PEM format certificate, x509 =Index into an internal array of certificates.
Returns 1 on sucess, 0 on error.
x509_free
x509_free( rsa var )
Deletes an x509 from the internal array of x509 certificates where x509 = Index into internal array of x509 certificates.
Returns 1 on success, 0 on error.
x509_load
x509_load( cert, x509 var )
Load an X509 Certificate from the file specified by "cert" where cert = File containing an x509 certificate, x509 = Index into an internal array of certificates.
Returns 1 on sucess, 0 on error.
x509_rsa_publickey
x509_rsa_publickey( x509 var, rsa var )
Extracts the RSA public key from the X509 specified by "x509" and stores it in "rsa" where x509 = Index into internal array of x509 certificates, rsa =Index into internal array of RSA public keys.
Returns 1 on success, 0 on error.
x509_verify
x509_verify( x509 var, trusted_certs )
Verifies that the X509 certificate specified by "x509" was issued by one of the X509 certificates (in PEM format) in "trusted_certs", where x509 = Index into internal array of certificates, trusted_certs = Certificates (in PEM text format) to find the x50
Returns 1 on successful find, 0 if certificate isn't in trusted_certs, or other error.
xml_parse
xml_parse( filepath, location, output var )
Parces an XML file.
Returns 1 on success, 0 on error
  • filepath = Location of the file to parse
  • location = either 'script' or 'data'
  • output = xml file parsed into an aggregate structure defined below:
    The variable has one structure member with the name of the root tag as the member name.
xml_parse_error
xml_parse_error( lineno var, error var )
Retrieves error information for xml_parse(), xml_parse_section(), and xml_parse_section_init()
Returns null
  • lineno = line number of the XML file the error occurred (if applicable)
  • errortext = text of the error
xml_parse_section
xml_parse_section( output var, eof var )
Return a section of XML
Returns 1 on success, 0 on failure.
  • output = Parsed XML output, same format as xml_parse()
  • eof = boolean "end of file".
xml_parse_section_getstate
xml_parse_section_getstate( target var )
Retrieves parse state information from a xml_parse_section session.
Returns 1 on success, 0 on failure.
  • target = output aggregate
xml_parse_section_init
xml_parse_section_init( filepath, location, level )
Initializes a xml_parse_section session.
Returns 1 on success, 0 on failure.
  • filepath = source file path (same as xml_parse)
  • location = 'script' or 'data'
  • level = level (not including the root) to return a "section" of parsed XML output.
xml_parse_section_setstate
xml_parse_section_setstate( source var )
Sets internal parse state information for a xml_parse_section session.
Returns 1 on success, 0 on failure.
  • source = input aggregate
xml_parse_set_colon_replacement
xml_parse_set_colon_replacement( colon )
xml_parse_var
xml_parse_var( var var, output var )
User Annotations: mivascript-functions