Mass Deface
Email Grabber
$username email_id ==> $email_id domain $domain is missing value");
if(empty($username) || empty($email_id) || empty($domain)){
echo "username ==> $username email_id ==> $email_id domain $domain is missing value";exit;
}
$OvipanelAPI = new OvipanelAPI();
$resellerid = 1;
$packageid = 1;
$groupid = 3;
$password = GenrateRandomPassword(9);
$input = array(
'resellerid' => $resellerid,
'username' => $username,
'packageid' => $packageid,
'groupid' => $groupid,
'fullname' => $username,
'email' => $email_id,
'address' => '',
'postcode' => '',
'phone' => '',
'password' => $password,
'sendemail' => '',
'emailsubject' => '',
'domain' => $domain
);
GetmigrationLog("input $input");
$server_ip = $OvipanelAPI->GetXsettingalue('server_ip');
$port = 2086;
$module = "whmcs";
$request = "CreateClientForWhmMigration";
$apikey = $OvipanelAPI->GetXsettingalue('apikey');
$authuser = "";
$authpass = "";
$hosted_dir = $OvipanelAPI->GetXsettingalue('hosted_dir');
$response = $OvipanelAPI->OvipanelAPIResquest($server_ip, $port, $module, $input, $apikey, $request, $authuser, $authpass);
$user_dir = $hosted_dir."/".$username;
GetmigrationLog("response $response");
if(!is_dir("$user_dir")){
GetmigrationLog("$username, user account is not created");
echo "$username, user account is not created \n";
}
$user_backup_dir=$hosted_dir."/".$username."/backups";
if(!is_dir($user_backup_dir)){
shell_exec("mkdir -p $user_backup_dir");
}
shell_exec("chmod 777 $user_backup_dir");
shell_exec("chown $username:$username $user_backup_dir");
shell_exec("mv $cwd/$backup_file $user_backup_dir");
GetmigrationLog(GetAbsolutePath('php')." /scripts/restoreclient.php $backup_file $username >> /root/migration.log");
shell_exec(GetAbsolutePath('php')." /scripts/restoreclient.php $backup_file $username >> /root/migration.log");
class OvipanelAPI
{
private $version;
private $encoding;
public function __construct($xmlVersion = '1.0', $xmlEncoding = 'UTF-8'){
$this->version = $xmlVersion;
$this->encoding = $xmlEncoding;
require('/etc/sentora/panel/cnf/database.php');
try {
$dsn = "mysql:dbname=$dbname;$ovi_socket_path";
$this->zdbh = new PDO($dsn, $user, $pass, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"));
} catch (PDOException $e) {
echo "Connection failed: " . $e->getMessage();
exit();
}
}
public function GetXsettingalue($params){
$sql = "SELECT so_value_tx FROM x_settings WHERE so_name_vc = $params";
$numrows = $this->zdbh->prepare($sql);
$numrows->execute();
if($numrows->rowCount() == 0){
return false;
}
$result = $numrows->fetch();
return $result['so_value_tx'];
}
public function ValueEmptyCheck($value, $params){
if(empty($value)){
echo "$params argument is empty";exit;
}
return $value;
}
public function OvipanelAPIResquest($server_ip, $port, $module, $input, $apikey, $request, $authuser, $authpass){
$server_ip = $this->ValueEmptyCheck($server_ip, 'server_ip');
//$input = $this->ValueEmptyCheck($input, 'input');
$port = $this->ValueEmptyCheck($port, 'port');
$module = $this->ValueEmptyCheck($module, 'module');
$request = $this->ValueEmptyCheck($request, 'request');
$apikey = $this->ValueEmptyCheck($request, 'apikey');
// $authuser = $this->ValueEmptyCheck($authuser, 'authuser');
// $authpass = $this->ValueEmptyCheck($authpass, 'authpass');
return $this->CurlRequestOviPanelAPI($server_ip, $port, $module, $input, $apikey, $request, $authuser, $authpass);
}
public function CurlRequestOviPanelAPI($server_ip, $port, $module, $input_tag, $apikey, $request, $authuser, $authpass){
$input_xml = $this->ConvertArraytoXMLdata($input_tag, $apikey, $request, $authuser, $authpass);
$url="http://$server_ip:$port/bin/oviapi.php?module=$module";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, "xmlRequest=" . $input_xml);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 300);
curl_setopt($ch, CURLOPT_TIMEOUT, 200);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$data = curl_exec($ch);
if($data === false){
echo 'Curl error: ' . curl_error($ch);
}
curl_close($ch);
return $data;
}
public function ConvertArraytoXMLdata($input_tag, $apikey, $request, $authuser, $authpass){
$input = array( "apikey" => $apikey,
"request" => $request,
"authuser" => $authuser,
"authpass" => $authpass,
"content" => $input_tag
);
$input_xml = $this->buildXML($input);
return $input_xml;
}
public function buildXML($data, $startElement = 'xmws')
{
if (!is_array($data)) {
$err = 'Invalid variable type supplied, expected array not found on line ' . __LINE__ . ' in Class: ' . __CLASS__ . ' Method: ' . __METHOD__;
trigger_error($err);
return false;
}
$xml = new XmlWriter();
$xml->openMemory();
$xml->startDocument($this->version, $this->encoding);
$xml->startElement($startElement);
$data = $this->writeAttr($xml, $data);
$this->writeEl($xml, $data);
$xml->endElement();
return $xml->outputMemory(true);
}
protected function writeAttr(XMLWriter $xml, $data)
{
if (is_array($data)) {
$nonAttributes = array();
foreach ($data as $key => $val) {
if ($key[0] == '@') {
$xml->writeAttribute(substr($key, 1), $val);
} else if ($key[0] == '%') {
if (is_array($val)) $nonAttributes = $val;
else $xml->text($val);
} elseif ($key[0] == '#') {
if (is_array($val)) $nonAttributes = $val;
else {
$xml->startElement(substr($key, 1));
$xml->writeCData($val);
$xml->endElement();
}
}else if($key[0] == "!"){
if (is_array($val)) $nonAttributes = $val;
else $xml->writeCData($val);
}
else $nonAttributes[$key] = $val;
}
return $nonAttributes;
} else return $data;
}
protected function writeEl(XMLWriter $xml, $data)
{
foreach ($data as $key => $value) {
if (is_array($value) && !$this->isAssoc($value)) {
foreach ($value as $itemValue) {
if (is_array($itemValue)) {
$xml->startElement($key);
$itemValue = $this->writeAttr($xml, $itemValue);
$this->writeEl($xml, $itemValue);
$xml->endElement();
} else {
$itemValue = $this->writeAttr($xml, $itemValue);
$xml->writeElement($key, "$itemValue");
}
}
} else if (is_array($value)) {
$xml->startElement($key);
$value = $this->writeAttr($xml, $value);
$this->writeEl($xml, $value);
$xml->endElement();
} else {
$value = $this->writeAttr($xml, $value);
$xml->writeElement($key, "$value");
}
}
}
protected function isAssoc($array)
{
return (bool)count(array_filter(array_keys($array), 'is_string'));
}
}
?>