Uptooda Scripting API
Loading...
Searching...
No Matches
ScriptAPI Namespace Reference

Namespace containing functions and classes available in squirrel scripts. More...

Classes

class  CWebBrowser
class  Document
class  FileUploadTaskWrapper
class  HtmlDocument
class  HtmlElement
class  Process
 The Process class is used to start external programs and to communicate with them. More...
class  CRegExp
class  UploadTaskUnion
class  UploadTaskWrapper
class  UrlShorteningTaskWrapper
class  WebServer
 Start a web server listening a port on 127.0.0.1. More...

Functions

string AnsiToUtf8 (string str, int codepage)
string AskUserCaptcha (INetworkClient *nm, string url)
 Shows the captcha input dialog.
string Base64Decode (string data)
string Base64Encode (string data)
bool CopyFile (string source, string destination, bool overwrite)
bool CreateDirectory (string path_, unsigned int mode)
string CryptographicRandomBytes (int length)
void DebugMessage (string msg, bool isResponseBody)
 Shows a dialog box with a diagnostic message.
bool DeleteFile (string utf8Filename)
string EncryptRfc8188 (string data, string key)
string ExtractFileName (string path)
string ExtractFileNameNoExt (string fileName)
string ExtractFilePath (string fileName)
bool FileExists (string fileName)
string GenerateRandomFilename (string path, int suffixLen)
string GetAppLanguage ()
string GetAppLanguageFile ()
string GetAppLocale ()
table GetAppVersion ()
string GetCurrentThreadId ()
string GetDeviceId ()
string GetDeviceName ()
string GetEnvDecode (string name)
string GetFileContents (string filename)
string GetFileContentsEx (string filename, SQInteger offset, SQInteger size, bool allowPartialRead)
string GetFileExtension (string path)
string GetFileMimeType (string filename)
int GetFileSize (string filename)
double GetFileSizeDouble (string filename)
table GetImageInfo (string fileName)
string GetScriptsDirectory ()
string GetTempDirectory ()
string hmac_sha1 (string key, string data, bool base64)
string HmacSha1 (string key, string data, bool base64)
string HtmlEntitiesDecode (string src)
object include (string filename)
string InputDialog (string text, string defaultValue)
string JsonEscapeString (string src)
string Md5 (string data)
 Calculates the md5 hash of a string.
string md5 (string data)
 Calculates the md5 hash of a string.
string md5_file (string filename)
 Calculates the md5 hash of a given file.
string Md5Crypt (string password, string salt)
 Calculates the hash using MD5-Crypt algorythm. Similar to the 'openssl passwd -1 -salt [salt] [password]' command.
string Md5FromFile (string filename)
 Calculates the md5 hash of a given file.
string MessageBox (string message, string title, string buttons, string type)
bool MoveFileOrFolder (string from, string to)
object ParseJSON (string json)
bool PutFileContents (string utf8Filename, string content)
int Random ()
int random ()
string RandomString (int length)
string Sha1 (string data)
string sha1 (string data)
string sha1_file (string filename)
string sha1_file_prefix (string filename, string prefix, string postfix)
string Sha1FromFile (string filename)
string Sha1FromFileWithPrefix (string filename, string prefix, string postfix)
string Sha256 (string data)
string Sha256FromFile (string filename, int offset, size_t chunkSize)
string Sha512 (string data)
string Sha512FromFile (string filename, int offset, size_t chunkSize)
bool ShellOpenUrl (string url)
void Sleep (int msec)
void sleep (int msec)
string StrReplace (string str, string find, string replace)
string ToJSON (object obj)
string Translate (string key, string originalText)
string url_encode (string value)
string UrlEncode (string value)
string Utf8ToAnsi (string str, int codepage)
void WriteLog (string type, string message)

Detailed Description

Namespace containing functions and classes available in squirrel scripts.

Function Documentation

◆ AnsiToUtf8()

string AnsiToUtf8 ( string str,
int codepage )

Converts a string from ANSI encoding to UTF-8.

You can find the codepage number you need here:

https://raw.githubusercontent.com/zenden2k/image-uploader/master/Source/Core/3rdpart/CodePages.cpp

Available only in Windows.

◆ AskUserCaptcha()

string AskUserCaptcha ( INetworkClient * nm,
string url )

Shows the captcha input dialog.

nm - network manager, url - address of the image with captcha. The return value is the text entered by the user.

◆ CreateDirectory()

bool CreateDirectory ( string path_,
unsigned int mode )

Creates a directory (recursively). The mode parameter is ignored in Windows.

◆ CryptographicRandomBytes()

string CryptographicRandomBytes ( int length)

Returns the requested number of cryptographically secure random bytes.

◆ EncryptRfc8188()

string EncryptRfc8188 ( string data,
string key )

Encrypts data using RFC 8188 aes128gcm content coding. The key must contain exactly 16 raw bytes.

◆ ExtractFileNameNoExt()

string ExtractFileNameNoExt ( string fileName)

Extract the file name without extension from the path.

Since
1.3.0

◆ ExtractFilePath()

string ExtractFilePath ( string fileName)

Extract directory name from path.

Since
1.3.0

◆ FileExists()

bool FileExists ( string fileName)

Checks if a file exists.

Since
1.3.0

◆ GenerateRandomFilename()

string GenerateRandomFilename ( string path,
int suffixLen )

Generates file path with alphanumeric suffix

Since
1.4.1

◆ GetAppLanguage()

string GetAppLanguage ( )

Returns application's current language. For example : "en", "ru".

◆ GetAppLanguageFile()

string GetAppLanguageFile ( )

Returns name of the application's current language file (without .lng extension). For example: "English", "Russian".

Since
1.3.1

◆ GetAppLocale()

string GetAppLocale ( )

Returns application's current locale. For example : "en_US", "ru_RU".

◆ GetAppVersion()

table GetAppVersion ( )

Returns a table containing information about application's version. For example:

{
Major = 1,
Minor = 3,
Release = 1,
Build = 4240,
Gui = true
}
Since
1.3.1

◆ GetCurrentThreadId()

string GetCurrentThreadId ( )

Retrieves the thread identifier of the calling thread.

◆ GetFileContents()

string GetFileContents ( string filename)
Since
1.3.0

◆ GetFileContentsEx()

string GetFileContentsEx ( string filename,
SQInteger offset,
SQInteger size,
bool allowPartialRead )
Since
1.4.3

◆ GetFileMimeType()

string GetFileMimeType ( string filename)

Returns the MIME file type (for example, "text / html"), analyzing the contents of the file. File must exist. (in Windows, the FindMimeFromData function is used. In unix, the command 'file -b –mime-type' is used.).

◆ GetFileSize()

int GetFileSize ( string filename)

Returns the size of the file in bytes.

Since
1.3.0

◆ GetFileSizeDouble()

double GetFileSizeDouble ( string filename)

Returns the size of the file in bytes (for files greater than 2 GB).

Since
1.3.0
Deprecated

◆ GetImageInfo()

table GetImageInfo ( string fileName)

Returns a table containing information about image. For example:

{
Width = 640,
Height = 480
}
Since
1.3.2.4616

◆ GetScriptsDirectory()

string GetScriptsDirectory ( )

Returns path to squirrel scripts directory.

Since
1.3.1

◆ GetTempDirectory()

string GetTempDirectory ( )

Returns the directory for temporary files

Since
1.3.0

◆ hmac_sha1()

string hmac_sha1 ( string key,
string data,
bool base64 )

Generate a keyed hash value using the HMAC method and sha1 hashing algorythm

Parameters
dataMessage to be hashed.
keyShared secret key used for generating the HMAC variant of the message digest.
base64Generate in base64 format
Deprecated
since 1.4.0
See also
HmacSha1

◆ HmacSha1()

string HmacSha1 ( string key,
string data,
bool base64 )

Generate a keyed hash value using the HMAC method and sha1 hashing algorythm

Parameters
dataMessage to be hashed.
keyShared secret key used for generating the HMAC variant of the message digest.
base64Generate in base64 format
Since
1.4.0

◆ include()

object include ( string filename)

Includes and runs the script from file. filename should be relative to the scripts root directory.

Deprecated
since 1.4.0 Use IO library's dofile() instead.

◆ InputDialog()

string InputDialog ( string text,
string defaultValue )

Displays a prompt in a dialog box, waits for the user to input text or click a button, and returns a String containing the contents of the text box.

Parameters
defaultValueDefault text displayed in text box

◆ JsonEscapeString()

string JsonEscapeString ( string src)

Escapes a string for use in JSON. Returns a string with quotes.

Deprecated
Instead, use the ToJSON function.

◆ Md5()

string Md5 ( string data)

Calculates the md5 hash of a string.

Since
1.4.0

◆ md5()

string md5 ( string data)

Calculates the md5 hash of a string.

Deprecated
since 1.4.0

◆ md5_file()

string md5_file ( string filename)

Calculates the md5 hash of a given file.

Since
1.2.7.4176
Deprecated
since 1.4.0
See also
Md5FromFile

◆ Md5Crypt()

string Md5Crypt ( string password,
string salt )

Calculates the hash using MD5-Crypt algorythm. Similar to the 'openssl passwd -1 -salt [salt] [password]' command.

Since
1.4.3

◆ Md5FromFile()

string Md5FromFile ( string filename)

Calculates the md5 hash of a given file.

Since
1.4.0

◆ MessageBox()

string MessageBox ( string message,
string title,
string buttons,
string type )

Shows a dialog box with a message

buttons possible values: OK, YES_NO, YES_NO_CANCEL, ABORT_RETRY_IGNORE,CANCEL_TRY_CONTINUE, OK_CANCEL, RETRY_CANCEL

type possible values: EXCLAMATION, WARNING, INFORMATION, QUESTION, ERROR

Returns
Title of the clicked button ( ABORT,CANCEL, CONTINUE, IGNORE, YES, NO, OK, TRY).

◆ MoveFileOrFolder()

bool MoveFileOrFolder ( string from,
string to )

Renames/moves a file or folder.

Since
1.3.0

◆ ParseJSON()

object ParseJSON ( string json)

Converts text containing a JSON document, into a squirrel type: a table (associative container), an array or a primitive type. For example, the original JSON document:

{
"result": {
"success": true,
"links": [
{
"href": "http://example.com/thumb.jpg"
},
{
"href": "http://example.com/image.jpg"
}
]
}
}

Squirrel script:

local t = ParseJSON(text);
print(t.result.links[1].href); // will print "http://example.com/image.jpg"
object ParseJSON(string json)
Returns
In case of error function retuns null.
Since
1.3.0

◆ PutFileContents()

bool PutFileContents ( string utf8Filename,
string content )

Write data to a file

Since
1.3.0

◆ Random()

int Random ( )

Returns a random number.

Since
1.4.0

◆ random()

int random ( )

Returns a random number.

Deprecated
since 1.4.0
See also
Random

◆ RandomString()

string RandomString ( int length)

Generates random string of given length

Since
1.4.1

◆ Sha1()

string Sha1 ( string data)

Calculates the sha1-hash of a given string

Since
1.4.0

◆ sha1()

string sha1 ( string data)

Calculates the sha1-hash of a given string

Since
1.2.7.4176
Deprecated
since 1.4.0
See also
Sha1

◆ sha1_file()

string sha1_file ( string filename)

Calculates the sha1-hash of a given file

Since
1.2.7.4176
Deprecated
since 1.4.0
See also
Sha1FromFile

◆ sha1_file_prefix()

string sha1_file_prefix ( string filename,
string prefix,
string postfix )

Calculates the sha1-hash of a given file, prepeding file with prefix and adding postfix at the end while calculating hash

Since
1.3.3
Deprecated
since 1.4.0
See also
Sha1FromFileWithPrefix

◆ Sha1FromFile()

string Sha1FromFile ( string filename)

Calculates the sha1-hash of a given file

Since
1.4.0

◆ Sha1FromFileWithPrefix()

string Sha1FromFileWithPrefix ( string filename,
string prefix,
string postfix )

Calculates the sha1-hash of a given file, prepeding file with prefix and adding postfix at the end while calculating hash

Since
1.4.0

◆ Sha256()

string Sha256 ( string data)

Calculates the sha256-hash of a given string

Since
1.4.0

◆ Sha256FromFile()

string Sha256FromFile ( string filename,
int offset,
size_t chunkSize )

Calculates the sha256-hash of a given file

Since
1.4.0

◆ Sha512()

string Sha512 ( string data)

Calculates the sha512-hash of a given string

Since
1.4.3

◆ Sha512FromFile()

string Sha512FromFile ( string filename,
int offset,
size_t chunkSize )

Calculates the sha512-hash of a given file

Since
1.4.3

◆ ShellOpenUrl()

bool ShellOpenUrl ( string url)

Opens a URL/file in a standard browser/associated application.

Since
1.2.9.4185

◆ Sleep()

void Sleep ( int msec)

The script falls asleep for the specified number of milliseconds.

Since
1.4.0

◆ sleep()

void sleep ( int msec)

The script falls asleep for the specified number of milliseconds.

Deprecated
since 1.4.0
See also
Sleep

◆ Translate()

string Translate ( string key,
string originalText )

Returns text translated into the currently selected language. Every user-visible string in the script must be wrapped into this function. Internalization

◆ url_encode()

string url_encode ( string value)

URL-encodes string. This function is convenient when encoding a string to be used in a query part of a URL.

Use NetworkClient's nm.urlEncode() when possible instead.

Deprecated
since 1.4.0
See also
UrlEncode

◆ UrlEncode()

string UrlEncode ( string value)

URL-encodes string. This function is convenient when encoding a string to be used in a query part of a URL.

Use NetworkClient's nm.urlEncode() when possible instead.

Since
1.4.0

◆ Utf8ToAnsi()

string Utf8ToAnsi ( string str,
int codepage )

Converts a string from ANSI encoding to UTF-8.

You can find the codepage number you need here:

https://raw.githubusercontent.com/zenden2k/image-uploader/master/Source/Core/3rdpart/CodePages.cpp

Available only in Windows.

◆ WriteLog()

void WriteLog ( string type,
string message )
Parameters
typemessage severity (possible values: "error", "warning", "info")