Skip to content
adobkin edited this page Feb 1, 2013 · 2 revisions

Examples of managing groups and stations via the php-avdesk module for PHP 5.3/5.4

Creating a Group

Task: Create a root user group named My_group. Group UUID must be generated automatically.

Implementation:

<?php
// Specifying parameters of the Dr.Web AV-Desk server
$server_handle = dwavd_init('localhost', 9080, 'admin', 'password');

// Initializing resource of a new group
$grp = dwavd_grp_init();
// Specifying the group name. 
dwavd_grp_set($grp, 'name', 'My_group');

// Creating the group, printing out its ID 
echo dwavd_grp_add($server_handle, $grp);

// Freeing up the resources
dwavd_grp_free($grp); 
dwavd_free($server_handle);
?>

Creating a Tariff Group

Task:

Create a tariff named New_Year. Tariff UUID must be generated automatically. Parent group: Tariffs (994992e8-be71-4d31-a1f5- 5b7786262611). Grace period: 10 days.

Implementation:

<?php
// Specifying parameters of the Dr.Web AV-Desk server
$server_handle = dwavd_init('localhost', 9080, 'admin', 'password');

// Initializing resource of a new tariff group
$trf = dwavd_trf_init(); 
dwavd_trf_set_array($trf,
array (
// Specifying the name of tariff group
'name'=>'New_Year',
// Specifying the grace period
'grace_period'=>10,
// Specifying the parent group
'parent_id'=>'994992e8-be71-4d31-a1f5-5b7786262611')
);

// Creating the tariff group, printing out its ID
echo dwavd_trf_add($server_handle, $trf);

// Freeing up the resources
dwavd_trf_free($trf); 
dwavd_free($server_handle);
?>

Creating a Station (Subscription)

Task:

Create new station. UUID must be generated automatically. Parent group: My_group (c060a9c0-8f75-4a8c-b2da-044aa0eb98b7). Tariff AV (Dr.Web Classic).

Implementation:

<?php
// Specifying parameters of the Dr.Web AV-Desk server
$server_handle = dwavd_init('localhost', 9080, 'admin', 'password');

// Initializing resource of a new station
$st = dwavd_st_init(); dwavd_st_set_array($st,
array (
// Specifying the parent group. 
'parent_id'=>'c060a9c0-8f75-4a8c-b2da-044aa0eb98b7',
// Specifying the tariff group
'tariff_id'=>'2888b7ff-3625-465e-bcb8- 957de17f6458',
) );

// Creating the station, printing out its ID
echo dwavd_st_add($server_handle, $st);

// Freeing up the resources
dwavd_st_free($st); 
dwavd_free($server_handle);
?>