php function cluster_xmlrpc return array array cluser createdomain clu

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
<?php
function cluster_xmlrpc()
{
return array(
array(
'cluser.createdomain',
'cluser_createdomain',
t('Create Domain')
)
);
}
function cluser_domains_load($domainname) {
return db_fetch_object(db_query('SELECT * FROM {module_clusterdomains} WHERE name = "%s"', $domainname));
}
function cluser_domains_edit($object) {
if ($object->cdid == 0) {
$query = new SqlQueryBuilder("insert");
unset($object->cdid);
} else {
$query = new SqlQueryBuilder("update");
$query->setWhere('cdid = '.$object->cdid);
unset($values->hid);
}
$query->setTable("module_clusterdomains");
foreach($values as $key => $value) {
$query->addColumn($key);
$query->addValue($value);
}
db_query($query->buildQuery());
}
function cluser_createdomain($domain, $type, $server, $username, $owner, $homedir) {
$domain = trim ($domain);
// Проверям домен
if (! preg_match ("/^[a-z0-9][a-z0-9\-]+[a-z0-9](\.[a-z]{2,4})+$/i", $domain)) {
$message->message = "Cluster :: Create Domain :: Domain wrong.";
$message->retcode = 1;
return $message;
};
if ($type != 'domain' && $type != 'alias' && $type != 'parked' ) {
$message->message = "Cluster :: Create Domain :: Domain type not supported (". $type .").";
$message->retcode = 2;
return $message;
}
$server = check_plain($server);
$server = server_load($server);
if ($server->serverobject->ipaddress != $_SERVER['REMOTE_ADDR'] ) {
$message->message = "Cluster :: Create Domain :: Access Denied (IP: ". $_SERVER['REMOTE_ADDR'] .").";
$message->retcode = 3;
return $message;
}
// Проверка пользователя
if ( trim($username) == '') {
$message->message = "Cluster :: Create Domain :: Username wrong.";
$message->retcode = 4;
return $message;
}
// Проверем на существование.
$cluserdomain = cluser_domains_load($domain);
if ($cluserdomain) {
$message->message = "Cluster :: Create Domain :: Domain already exist on server ". $cluserdomain->server .".";
$message->retcode = 5;
return $message;
}
$cluser_domains = '';
$cluser_domains->domain = $domain;
$cluser_domains->type = $type;
$cluser_domains->server = $server;
$cluser_domains->username = $username;
$cluser_domains->owner = $owner;
$cluser_domains->homedir = $homedir;
cluser_domains_edit($cluser_domains);
$message = '';
$message->retcode = 0;
$message->message = "Cluster :: Create Domain :: Operation Succesfull";
return $message;
}
?>