addTarget() (tick_24Batch Wizard Only, tick_24Enterprise Only)

void addTarget(array $target);

NOTE: This function is only available in the enterprise edition.

Adds a target to a synchronized list of targets to be processed. Synchronized targets are downloaded one by one before other targets. This allows cookies to be set correctly.

Use addTarget_ASync() instead to add the target to the asynchronous list of targets to be processed.

$target is an array containing the following keys:

$target.flags (required)

8 - target is a file target

16 - target is a folder target

32 - target is a URL target

64 - include subfolders (when using flag 16)

must include one of the following flags: 8, 16, or 32

$target.moreflags

1 - follow links

$target.target - the full path or absolute URL of the target (required)

When links are being followed, the following optional variables may be set:

$target.followdepthlimit - the depth to follow links to (-1 is assumed if not set, which means no limit)

$target.followextensions - extensions to follow (comma separated list of file extensions; the default list of extensions to follow is used if not set)

$target.followlimitto - only follow links that begin with this string (the default is used if not set, which usually limits to domain and path)

$target.followmimetypes - MIME types to follow (comma separated list of MIME types; the default list of MIME types to follow is used if not set)

$target.nofollowextensions - extensions not to follow (comma separated list of file extensions; the default list of extensions not to follow is used if not set)

When the target is a URL (flag 32), the following optional variables may be set:

$target.acceptlanguage - set the contents of the Accept-Language header

$target.method - set to 'POST' (case-insensitive and without the quotes) to override the default method (which is GET)

$target.nodefaultcookies - set to non-zero to cancel any default cookies from being sent

$target.password - the HTTP/NTLM authentication password to use; $target.username must be supplied

$target.postcontenttype - when posting, set the Content-Type (by default application/x-www-form-urlencoded is used)

$target.proxy - set to override the default proxy for this target

$target.proxyport - set to override the default proxy port for this target

$target.proxypassword - set to override the default proxy password for this target

$target.proxyusername - set to override the default proxy username for this target

$target.requestver - set to override the default HTTP request version (the default is '1.1')

$target.sendstring - when posting, the data (as a string) to post

$target.useragent - set to override the default user agent string

$target.username - the HTTP/NTLM authentication username to use

Causes the onTargetAdd() event function to be called if successful

Good to use in the onBeforeMainStart() event

By default, this function adds URL targets even if the target appears to have already been added. This allows adding similar targets but with different options/settings (like different POST variables).

Example 1 (simple POST with an email address):

function onBeforeMainStart() {
 $target.flags=32; // URL target
 $target.method='POST'; // use POST instead of GET
 $target.sendstring='email='+encodeUrl('someone@domain.com')
 $target.target='http://www.domain.com/form.php';
 addTarget($target);
}

Example 2 (POST to a login form & follow the links):

function onBeforeMainStart() {
 $target.flags=32; // URL target
 $target.moreflags=1; // follow links
 $target.followdepthlimit=2; // don't go too deep
 $target.method='POST'; // use POST instead of GET
 $target.sendstring='username='+encodeUrl('someone@domain.com')+'&password='+encodeUrl('password');
 $target.target='https://www.domain.com/login.php';
 addTarget($target);
}