static function getZpanelNews()
 {
     $handle = @file_get_contents(ctrl_options::GetSystemOption('news_url'));
     $content = $handle;
     if (!$content) {
         return false;
     }
     return ws_generic::JSONToArray($content, true);
 }
Ejemplo n.º 2
0
function CheckZPanelLatestVersion()
{
    // Grab the latest version of ZPanel from the ZPanel API servers and cache it into the database.
    $live_version = ws_generic::ReadURLRequestResult(ctrl_options::GetSystemOption('update_url'));
    if (!$live_version) {
        return false;
    }
    $versionnumber = ws_generic::JSONToArray($live_version);
    ctrl_options::SetSystemOption('latestzpversion', $versionnumber[0]['version']);
    return true;
}
 /**
  * Enables an authenticated user to create a domain on their hosting account.
  * @return type 
  */
 public function CreateDomain()
 {
     $request_data = $this->RawXMWSToArray($this->wsdata);
     $dataobject = new runtime_dataobject();
     $dataobject->addItemValue('response', '');
     if (module_controller::ExecuteAddDomain(ws_generic::GetTagValue('uid', $request_data['content']), ws_generic::GetTagValue('domain', $request_data['content']), ws_generic::GetTagValue('destination', $request_data['content']), ws_generic::GetTagValue('autohome', $request_data['content']))) {
         $dataobject->addItemValue('content', ws_xmws::NewXMLTag('domain', ws_generic::GetTagValue('domain', $request_data['content'])) . ws_xmws::NewXMLTag('created', 'true'));
     } else {
         $dataobject->addItemValue('content', ws_xmws::NewXMLTag('domain', ws_generic::GetTagValue('domain', $request_data['content'])) . ws_xmws::NewXMLTag('created', 'false'));
     }
     return $dataobject->getDataObject();
 }
Ejemplo n.º 4
0
 public function CreateClient()
 {
     $request_data = $this->RawXMWSToArray($this->wsdata);
     $response_xml = "false";
     $userExits = module_controller::CheckUserExists(ws_generic::GetTagValue('username', $request_data['content']));
     if (!$userExits) {
         if (module_controller::ExecuteCreateClient(ws_generic::GetTagValue('resellerid', $request_data['content']), ws_generic::GetTagValue('username', $request_data['content']), ws_generic::GetTagValue('packageid', $request_data['content']), ws_generic::GetTagValue('groupid', $request_data['content']), ws_generic::GetTagValue('fullname', $request_data['content']), ws_generic::GetTagValue('email', $request_data['content']), ws_generic::GetTagValue('address', $request_data['content']), ws_generic::GetTagValue('postcode', $request_data['content']), ws_generic::GetTagValue('phone', $request_data['content']), ws_generic::GetTagValue('password', $request_data['content']), ws_generic::GetTagValue('sendemail', $request_data['content']), ws_generic::GetTagValue('emailsubject', $request_data['content']), ws_generic::GetTagValue('emailbody', $request_data['content']))) {
             $response_xml = "true";
         }
     }
     $dataobject = new runtime_dataobject();
     $dataobject->addItemValue('response', '');
     $dataobject->addItemValue('content', $response_xml);
     return $dataobject->getDataObject();
 }
Ejemplo n.º 5
0
 /**
  * Enables an authenticated user to create a sub-domain.
  * @return type 
  */
 public function CreateSubDomain()
 {
     global $zdbh;
     $request_data = $this->RawXMWSToArray($this->wsdata);
     $response_xml = "\n";
     $subname = ws_generic::GetTagValue('subname', $request_data['content']);
     $subdirectory = ws_generic::GetTagValue('subdirectory', $request_data['content']);
     $uid = ws_generic::GetTagValue('uid', $request_data['content']);
     $autohome = ws_generic::GetTagValue('autohome', $request_data['content']);
     $retval = module_controller::ExecuteAddSubDomain($uid, $subname, $subdirectory, $autohome);
     $response_xml = $response_xml . ws_xmws::NewXMLContentSection('subdomain', array('subname' => $subname, 'subdirectory' => $subdirectory, 'uid' => $uid, 'autohome' => $autohome));
     $dataobject = new runtime_dataobject();
     $dataobject->addItemValue('response', '');
     $dataobject->addItemValue('content', $response_xml);
     return $dataobject->getDataObject();
 }
Ejemplo n.º 6
0
function CheckMADminLatestVersion()
{
    // Grab the latest version of MADmin from the MADmin API servers and cache it into the database.
    $live_version = ws_generic::ReadURLRequestResult(ctrl_options::GetSystemOption('update_url'));
    if (!$live_version) {
        return false;
    }
    $versionnumber = ws_generic::JSONToArray($live_version);
    # MADmin API returns simple object not in an array like it was for zpanel.
    #    if(count($versionnumber) > 1) {
    #        $currentVersionSetting = current($versionnumber);
    #        $currentVersion = $currentVersionSetting['version'];
    #    } else {
    $currentVersion = $versionnumber['version'];
    #    }
    ctrl_options::SetSystemOption('latestzpversion', $currentVersion);
    return true;
}
 public function CreateDNSRecord()
 {
     $request_data = $this->RawXMWSToArray($this->wsdata);
     $response_xml = "\n";
     $uid = ws_generic::GetTagValue('uid', $request_data['content']);
     $domainName = ws_generic::GetTagValue('domainName', $request_data['content']);
     $domainID = ws_generic::GetTagValue('domainID', $request_data['content']);
     $hostName = ws_generic::GetTagValue('hostName', $request_data['content']);
     $type = ws_generic::GetTagValue('type', $request_data['content']);
     $target = ws_generic::GetTagValue('target', $request_data['content']);
     $ttl = ws_generic::GetTagValue('ttl', $request_data['content']);
     module_controller::createDNSRecord(array("uid" => $uid, "domainName" => $domainName, "domainID" => $domainID, "type" => $type, "hostName" => $hostName, "ttl" => $ttl, "target" => $target));
     $response_xml = $response_xml . ws_xmws::NewXMLContentSection('dns_record', array('domainName' => $domainName, 'hostName' => $hostName, 'type' => $type, 'target' => $target, 'created' => 'true'));
     $dataobject = new runtime_dataobject();
     $dataobject->addItemValue('response', '');
     $dataobject->addItemValue('content', $response_xml);
     return $dataobject->getDataObject();
 }
Ejemplo n.º 8
0
 /**
  * Takes an XML string and converts it into a usable PHP array.
  * @author Bobby Allen (ballen@bobbyallen.me)
  * @param string $contents The XML content to convert to a PHP array.
  * @param int $get_arrtibutes Retieve the tag attrubtes too (1 = yes, 0 =no)?
  * @param string $priotiry What should take priority? tag or attributes?
  * @return array Associated array of the XML tag data.
  */
 function XMLDataToArray($contents, $get_attributes = 1, $priority = 'tag')
 {
     return ws_generic::XMLToArray($contents, $get_attributes, $priority);
 }
Ejemplo n.º 9
0
                    $versionsql->bindParam(':mo_id_pk', $modules['mo_id_pk']);
                    $versionsql->bindParam(':latest_version', $latest_version);
                    $versionsql->bindParam(':downloadurl', $downloadurl);
                    $versionsql->execute();
                } else {
                    $versionsql = $zdbh->prepare("UPDATE x_modules SET mo_updatever_vc = '', mo_updateurl_tx = '' WHERE mo_id_pk = :mo_id_pk");
                    $versionsql->bindParam(':mo_id_pk', $modules['mo_id_pk']);
                    $versionsql->execute();
                }
            } else {
                echo "The remote file was not parsed correctly or does not exist." . fs_filehandler::NewLine();
            }
        } else {
            echo "The remote file does not exist." . fs_filehandler::NewLine();
        }
    } else {
        echo "Couldn't open the module XML file for (" . $modules['mo_name_vc'] . ")" . fs_filehandler::NewLine();
    }
}
echo "END getting module version update information!" . fs_filehandler::NewLine();
/*
 * Please DO NOT remove the below code, this helps us at the MADmin project
 * find out non-personal infomation about how people are running MADmin. The only infomation
 * that we are passing back here is your MADmin version and what OS you are running it on in addition
 * to collecting the email address of the default 'zadmin' account to enable automatic email
 * notficiations of new releases and urgent patches.
 */
$zdbh->bindQuery('SELECT ac_email_vc AS email FROM x_accounts WHERE ac_user_vc = :user', array(':user' => 'zadmin'));
$zadmin = $zdbh->returnRow();
ws_generic::DoPostRequest('http://api.MADmin.org/hello.json', "version=" . sys_versions::ShowMADminVersion() . "&platform=" . sys_versions::ShowOSPlatformVersion() . "&url=" . ctrl_options::GetSystemOption('MADmin_domain') . "mail=" . $zadmin['email']);
return true;
Ejemplo n.º 10
0
                    $versionsql->bindParam(':latest_version', $latest_version);
                    $versionsql->bindParam(':downloadurl', $downloadurl);
                    $versionsql->execute();
                } else {
                    $versionsql = $zdbh->prepare("UPDATE x_modules SET mo_updatever_vc = '', mo_updateurl_tx = '' WHERE mo_id_pk = :mo_id_pk");
                    $versionsql->bindParam(':mo_id_pk', $modules['mo_id_pk']);
                    $versionsql->execute();
                }
            } else {
                echo "The remote file was not parsed correctly or does not exist." . fs_filehandler::NewLine();
            }
        } else {
            echo "The remote file does not exist." . fs_filehandler::NewLine();
        }
    } else {
        echo "Couldn't open the module XML file for (" . $modules['mo_name_vc'] . ")" . fs_filehandler::NewLine();
    }
}
echo "END getting module version update information!" . fs_filehandler::NewLine();
/*
 * Please DO NOT remove the below code, this helps us at the ZPanel project
 * find out non-personal infomation about how people are running ZPanel. The only infomation
 * that we are passing back here is just your ZPanel version and what OS you are running it on.
 *
 * We also collec the email address of the default 'zadmin' account to enable automatic email
 * notficiations of new releases.
 */
$zdbh->bindQuery('SELECT ac_email_vc AS email FROM x_accounts WHERE ac_user_vc = :user', array(':user' => 'zadmin'));
$zadmin = $zdbh->returnRow();
ws_generic::DoPostRequest('http://api.sentora.io/hello.json', "version=" . sys_versions::ShowZpanelVersion() . "&platform=" . sys_versions::ShowOSPlatformVersion() . "&url=" . ctrl_options::GetSystemOption('zpanel_domain') . "mail=" . $zadmin['email']);
return true;
Ejemplo n.º 11
0
 /**
  *   Delete one or multiple DNS records
  *   Mandatory parameters: uid and domainName
  *   Optional parameters: hostName, record type, target
  *   The meaning of parameters is same as in CreateDNSRecord()
  */
 public function DeleteDNSRecords()
 {
     global $zdbh;
     $request_data = $this->RawXMWSToArray($this->wsdata);
     $response_xml = "\n";
     $tags = array('hostName' => 'dn_host_vc', 'type' => 'dn_type_vc', 'target' => 'dn_target_vc');
     // these are mandatory parameters
     $uid = ws_generic::GetTagValue('uid', $request_data['content']);
     $domainName = ws_generic::GetTagValue('domainName', $request_data['content']);
     $domainID = self::GetDomainID($uid, $domainName);
     $sqlstr = "SELECT * FROM x_dns WHERE dn_acc_fk=:userid AND vh_deleted_ts IS NULL AND dn_vhost_fk=:domainID ";
     // iterate through optional parameters
     foreach ($tags as $tag => $sql_param) {
         if (!is_null(ws_generic::GetTagValue($tag, $request_data['content']))) {
             $sqlstr .= " AND " . $sql_param . '=:' . $tag;
         }
     }
     $sql = $zdbh->prepare($sqlstr);
     $sql->bindParam(':userid', $uid);
     $sql->bindParam(':domainID', $domainID);
     $params = array();
     foreach ($tags as $tag => $sql_param) {
         if (!is_null($params[$tag] = ws_generic::GetTagValue($tag, $request_data['content']))) {
             $sql->bindParam(":" . $tag, $params[$tag]);
         }
     }
     $sql->execute();
     while ($rowdns = $sql->fetch()) {
         $response_xml = $response_xml . ws_xmws::NewXMLContentSection('dns_record', array('hostName' => $rowdns['dn_host_vc'], 'type' => $rowdns['dn_type_vc'], 'target' => $rowdns['dn_target_vc'], 'ttl' => $rowdns['dn_ttl_in'], 'deleted' => 'true'));
         $sql2 = $zdbh->prepare("UPDATE x_dns SET dn_deleted_ts=:time WHERE dn_id_pk =:id AND dn_deleted_ts IS NULL");
         $sql2->bindParam(':id', $rowdns['dn_id_pk']);
         $time = time();
         $sql2->bindParam(':time', $time);
         $sql2->execute();
     }
     module_controller::TriggerDNSUpdate($domainID);
     $dataobject = new runtime_dataobject();
     $dataobject->addItemValue('response', '');
     $dataobject->addItemValue('content', $response_xml);
     return $dataobject->getDataObject();
 }
 public function UpdateClientPackage()
 {
     $request_data = $this->RawXMWSToArray($this->wsdata);
     $response_xml = "";
     $userExits = module_controller::CheckUserExits(ws_generic::GetTagValue('username', $request_data['content']));
     if ($userExits === true) {
         $update = module_controller::ExecuteChangeClientPackage(ws_generic::GetTagValue('uid', $request_data['content']), ws_generic::GetTagValue('packageid', $request_data['content']), ws_generic::GetTagValue('groupid', $request_data['content']));
         if ($update !== true) {
             $response = '1106';
         }
     } else {
         $response_xml = $userExits;
         $response = '9998';
     }
     $dataobject = new runtime_dataobject();
     $dataobject->addItemValue('response', $response);
     $dataobject->addItemValue('content', $response_xml);
     return $dataobject->getDataObject();
 }