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_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_rand_bytes
crypto_rand_bytes( n )
Generates n random bytes.
Returns a string of bytes
  • n = the number of bytes
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.
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, '&lt;' 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 URL or part of an URL) in URL-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.
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 '&lt;'). This function is the opposite of decodeentities.
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
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
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 )
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, replace )
Works like glosub(), but search and replace are arrays that are iterated through, each value in the search array found in the string is replaced by the corresponding replace array value.
unknown.
  • string = the target array
  • search = the sub-string that will be searched for
  • replace = the replacement string
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
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_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_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_max
miva_array_max( aggregate var )
Return the maximum array_variable index used.
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_previous
miva_array_previous( aggregate var, index )
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_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_closelog
miva_closelog()
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_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 )
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 )
miva_struct_members
miva_struct_members( aggregate var, members var )
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 )
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 the RSA indicated by rsa.
Returns 1 on success, 0 on error.
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.
rsa_generate_keypair_mem
rsa_generate_keypair_mem( pubkey var, privkey var, bits, e, passphrase )
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.
rsa_load_privatekey_mem
rsa_load_privatekey_mem( privkey, rsa var, passphrase )
rsa_load_publickey
rsa_load_publickey( pubkey_file, rsa var )
Load an RSA public key from a PKCS#1 file specified by "pubkey_file".
rsa_load_publickey_mem
rsa_load_publickey_mem( pubkey, rsa var )
rsa_private_decrypt
rsa_private_decrypt( rsa, encrypted, plaintext var )
Decrypts the data in encrypted, storing the result in plaintext, using the private key portion of the RSA structure specified by rsa.
Returns 1 on success, 0 on error.
rsa_private_encrypt
rsa_private_encrypt( rsa, plaintext, encrypted var )
Encrypts the data in plaintext, storing the result in encrypted, using the private key portion of the RSA structure specified by rsa.
Returns 1 on success, 0 on error.
rsa_public_decrypt
rsa_public_decrypt( rsa, encrypted, plaintext var )
Decrypt the data in encrypted, storing the result in plaintext, using the public key portion of the RSA structure specified by rsa.
Returns 1 on success, 0 on error.
rsa_public_encrypt
rsa_public_encrypt( rsa, plaintext, encrypted var )
Encrypt the data in plaintext, storing the result in encrypted, using the public key portion of the RSA structure specified by rsa.
Returns 1 on success, 0 on error.
rsa_save_privatekey
rsa_save_privatekey( privkey_file, rsa var, passphrase )
rsa_save_privatekey_mem
rsa_save_privatekey_mem( privkey var, rsa var, passphrase )
rsa_sign
rsa_sign( rsa, buffer, signature var )
Sign the data in "buffer" with the RSA private key specified by "rsa", returning the result in "signature" where rsa = Value returned from one of the rsa_load_key routines, buffer = Buffer to sign, signature = Resulting signature.
Returns 1 on success, 0 on failure. Requires OpenSSL 0.9.7 or greater.
rsa_verify
rsa_verify( rsa, buffer, signature )
Verify the data in "buffer" with the RSA public key specified by "rsa" and the signature in "signature" where rsa = Value returned from one of the rsa_load_key routines, buffer = Buffer to sign, signature = Signature.
Returns 1 on success, 0 on verification failure or error. Requires OpenSSL 0.9.7 or greater.
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 )
Appends data to the end of the file in path.
Returns length of outputdata or 0 if fails.
  • path = fully qualified path to the file
  • location = location of the output file - 'data' or 'script'
  • outputdata = string variable containing the data to append
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
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
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.
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'
timezone
timezone()
Returns an integer which is the number of hours behind or ahead of GMT (not accounting for Daylight Time)
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'
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 )
srandom
srandom( seed )
Allows a script to reseed the random number generator used by random()
miva_template_compile
miva_template_compile( signat, source var, sourceitems var, target, errors var )
Compiles the contents of a string into a template file where sig = Any text. The md5 hash value of this text will be stored in the MVC file, source = The source to compile into a template file, items = array of valid item names. The compiler will return
User Annotations: mivascript-functions