/**
  * Generate a new API key and add it to the database. 
  */
 static function doGenerate()
 {
     $new_random_key = sha1(rand() . ctrl_options::GetOption('server_ip'));
     ctrl_options::SetSystemOption('apikey', $new_random_key);
     self::$updated = true;
     return true;
 }
Ejemplo n.º 2
0
 static function doUpdateConfig()
 {
     global $zdbh;
     global $controller;
     runtime_csfr::Protect();
     $sql = "SELECT * FROM x_settings WHERE so_module_vc=:name AND so_usereditable_en = 'true'";
     //$numrows = $zdbh->query($sql);
     $name = ui_module::GetModuleName();
     $numrows = $zdbh->prepare($sql);
     $numrows->bindParam(':name', $name);
     $numrows->execute();
     if ($numrows->fetchColumn() != 0) {
         $sql = $zdbh->prepare($sql);
         $sql->bindParam(':name', $name);
         $sql->execute();
         while ($row = $sql->fetch()) {
             if (!fs_director::CheckForEmptyValue($controller->GetControllerRequest('FORM', $row['so_name_vc']))) {
                 $updatesql = $zdbh->prepare("UPDATE x_settings SET so_value_tx = :name2 WHERE so_name_vc = :so_name_vc");
                 $name2 = $controller->GetControllerRequest('FORM', $row['so_name_vc']);
                 $updatesql->bindParam(':name2', $name2);
                 $updatesql->bindParam(':so_name_vc', $row['so_name_vc']);
                 $updatesql->execute();
             }
         }
     }
     self::$ok = true;
 }
Ejemplo n.º 3
0
 public function __construct()
 {
     parent::__construct();
     $this->rdata = $this->read();
     $this->smarty_assign("modules", $this->rdata);
     $this->add_button("add_new", 'go_to_add_module');
 }
Ejemplo n.º 4
0
 /**
  * Returns the status of all standard ZPanel hosting ports and the current server uptime.
  * @author Bobby Allen (ballen@bobbyallen.me)
  * @return type 
  */
 function GetServiceStatus()
 {
     $response_xml = ws_xmws::NewXMLContentSection('portstatus', array('web' => module_controller::getIsWebServerUp() == '' ? 0 : 1, 'ftp' => module_controller::getIsFTPUp() == '' ? 0 : 1, 'pop3' => module_controller::getIsPOP3Up() == '' ? 0 : 1, 'imap' => module_controller::getIsIMAPUp() == '' ? 0 : 1, 'smtp' => module_controller::getIsSMTPUp() == '' ? 0 : 1, 'mysql' => module_controller::getIsMySQLUp() == '' ? 0 : 1));
     $response_xml .= ws_xmws::NewXMLTag('serveruptime', sys_monitoring::ServerUptime());
     $dataobject = new runtime_dataobject();
     $dataobject->addItemValue('response', '');
     $dataobject->addItemValue('content', $response_xml);
     return $dataobject->getDataObject();
 }
Ejemplo n.º 5
0
 /**
  * Resets a user's ZPanel account password. Requires <uid> and <newpassword> tags.
  * @return type 
  */
 function ResetUserPassword()
 {
     $contenttags = $this->XMLDataToArray($this->wsdata);
     $dataobject = new runtime_dataobject();
     $dataobject->addItemValue('response', '');
     if (module_controller::UpdatePassword($contenttags['xmws']['content']['uid'], $contenttags['xmws']['content']['newpassword'])) {
         $dataobject->addItemValue('content', ws_xmws::NewXMLTag('uid', $contenttags['xmws']['content']['uid']) . ws_xmws::NewXMLTag('reset', 'true'));
     } else {
         $dataobject->addItemValue('content', ws_xmws::NewXMLTag('uid', $contenttags['xmws']['content']['uid']) . ws_xmws::NewXMLTag('reset', 'false'));
     }
     return $dataobject->getDataObject();
 }
 /**
  * Delete a specified domain using the content <domainid> tag to pass the domain DB ID through.
  * @return type 
  */
 public function DeleteDomain()
 {
     $request_data = $this->RawXMWSToArray($this->wsdata);
     $contenttags = $this->XMLDataToArray($request_data['content']);
     $dataobject = new runtime_dataobject();
     $dataobject->addItemValue('response', '');
     if (module_controller::ExecuteDeleteDomain($contenttags['domainid'])) {
         $dataobject->addItemValue('content', ws_xmws::NewXMLTag('domainid', $contenttags['domainid']) . ws_xmws::NewXMLTag('deleted', 'true'));
     } else {
         $dataobject->addItemValue('content', ws_xmws::NewXMLTag('domainid', $contenttags['domainid']) . ws_xmws::NewXMLTag('deleted', 'false'));
     }
     return $dataobject->getDataObject();
 }
Ejemplo n.º 7
0
 public function UsernameExists()
 {
     $request_data = $this->RawXMWSToArray($this->wsdata);
     $contenttags = $this->XMLDataToArray($request_data['content']);
     $UsernameExists = module_controller::CheckUserExists($contenttags['username']);
     $response = "false";
     if ($UsernameExists) {
         $response = "true";
     }
     $dataobject = new runtime_dataobject();
     $dataobject->addItemValue('response', '');
     $dataobject->addItemValue('content', $response);
     return $dataobject->getDataObject();
 }
Ejemplo n.º 8
0
 static function doUpdatePassword()
 {
     global $zdbh;
     global $controller;
     runtime_csfr::Protect();
     $currentuser = ctrl_users::GetUserDetail();
     $current_pass = $controller->GetControllerRequest('FORM', 'inCurPass');
     $newpass = $controller->GetControllerRequest('FORM', 'inNewPass');
     $conpass = $controller->GetControllerRequest('FORM', 'inConPass');
     $crypto = new runtime_hash();
     $crypto->SetPassword($newpass);
     $randomsalt = $crypto->RandomSalt();
     $crypto->SetSalt($randomsalt);
     $new_secure_password = $crypto->CryptParts($crypto->Crypt())->Hash;
     $sql = $zdbh->prepare("SELECT ac_pass_vc, ac_passsalt_vc FROM x_accounts WHERE ac_id_pk= :uid");
     $sql->bindParam(':uid', $currentuser['userid']);
     $sql->execute();
     $result = $sql->fetch();
     $userpasshash = new runtime_hash();
     $userpasshash->SetPassword($current_pass);
     $userpasshash->SetSalt($result['ac_passsalt_vc']);
     $current_secure_password = $userpasshash->CryptParts($userpasshash->Crypt())->Hash;
     if (fs_director::CheckForEmptyValue($newpass)) {
         // Current password is blank!
         self::$error = "error";
     } elseif ($current_secure_password != $result['ac_pass_vc']) {
         // Current password does not match!
         self::$error = "nomatch";
     } else {
         if ($newpass == $conpass) {
             // Check for password length...
             if (strlen($newpass) < ctrl_options::GetSystemOption('password_minlength')) {
                 self::$badpassword = true;
                 return false;
             }
             // Check that the new password matches the confirmation box.
             $sql = $zdbh->prepare("UPDATE x_accounts SET ac_pass_vc=:new_secure_password, ac_passsalt_vc= :randomsalt WHERE ac_id_pk=:userid");
             $sql->bindParam(':randomsalt', $randomsalt);
             $sql->bindParam(':new_secure_password', $new_secure_password);
             $sql->bindParam(':userid', $currentuser['userid']);
             $sql->execute();
             self::$error = "ok";
         } else {
             self::$error = "error";
         }
     }
 }
 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.º 10
0
 /**
  * Get and return package details for a specific package.
  * @return array
  */
 public function GetPackageId()
 {
     $request_data = $this->RawXMWSToArray($this->wsdata);
     $contenttags = $this->XMLDataToArray($request_data['content']);
     $packageId = 0;
     $response_xml = "\n";
     $allpackages = module_controller::ListPackages(1);
     foreach ($allpackages as $package) {
         if ($package['packagename'] === $contenttags['pakagename']) {
             $packageId = $package['packageid'];
         }
     }
     $response_xml = $response_xml . ws_xmws::NewXMLContentSection('pakageid', $packageId);
     $dataobject = new runtime_dataobject();
     $dataobject->addItemValue('response', '');
     $dataobject->addItemValue('content', $response_xml);
     return $dataobject->getDataObject();
 }
Ejemplo n.º 11
0
 /**
  * Run
  * PHP5.4: Declaration of users_controller::run() should be compatible with front_controller::run($route, $params) : 2048
  * @return template
  */
 public function run($r, $params = null)
 {
     // base routes
     if ($this->router->get_current_route()) {
         return parent::run($r, $params);
     }
     $this->set_section_name('users');
     // default action
     if (empty($r->action)) {
         $r->action = 'users';
     }
     $this->set_req($r);
     if (!is_callable(array($this, $r->action))) {
         throw new controller_exception('No such action', router_exception::ERROR);
     }
     // call method
     core::dprint('users_controller::' . $r->action);
     call_user_func(array($this, $r->action), $r);
     return $this->get_template();
 }
Ejemplo n.º 12
0
 public static function getServices()
 {
     global $controller;
     if (file_exists(ui_tpl_assetfolderpath::Template() . 'img/modules/' . $controller->GetControllerRequest('URL', 'module') . '/assets/up.gif') && file_exists(ui_tpl_assetfolderpath::Template() . 'img/modules/' . $controller->GetControllerRequest('URL', 'module') . '/assets/down.gif')) {
         $iconpath = '<img src="' . ui_tpl_assetfolderpath::Template() . 'img/modules/' . $controller->GetControllerRequest('URL', 'module') . '/assets/';
     } else {
         $iconpath = '<img src="modules/' . $controller->GetControllerRequest('URL', 'module') . '/assets/';
     }
     $line = "<h2>" . ui_language::translate("Checking status of services...") . "</h2>";
     $line .= "<table>";
     $status = fs_director::CheckForEmptyValue(sys_monitoring::PortStatus($PortNum));
     $line .= '<tr><th>HTTP</th><td>' . module_controller::status_port(80, $iconpath) . '</td></tr>';
     $line .= '<tr><th>FTP</th><td>' . module_controller::status_port(21, $iconpath) . '</td></tr>';
     $line .= '<tr><th>SMTP</th><td>' . module_controller::status_port(25, $iconpath) . '</td></tr>';
     $line .= '<tr><th>POP3</th><td>' . module_controller::status_port(110, $iconpath) . '</td></tr>';
     $line .= '<tr><th>IMAP</th><td>' . module_controller::status_port(143, $iconpath) . '</td></tr>';
     $line .= '<tr><th>MySQL</th><td>' . module_controller::status_port(3306, $iconpath) . '</td></tr>';
     $line .= '<tr><th>DNS</th><td>' . module_controller::status_port(53, $iconpath) . '</td></tr>';
     $line .= '</table>';
     $line .= '<br><h2>' . ui_language::translate('Server Uptime') . '</h2>';
     $line .= ui_language::translate('Uptime') . ": " . sys_monitoring::ServerUptime();
     return $line;
 }
Ejemplo n.º 13
0
 public function __construct()
 {
     parent::__construct();
 }
Ejemplo n.º 14
0
 static function doResetPassword()
 {
     global $controller;
     runtime_csfr::Protect();
     $formvars = $controller->GetAllControllerRequests('FORM');
     if (self::ExecuteResetPassword($formvars['inReset'], $formvars['inPassword'])) {
         self::$ok = true;
     }
     return true;
 }
Ejemplo n.º 15
0
 static function doDeleteBackup()
 {
     global $zdbh;
     global $controller;
     runtime_csfr::Protect();
     $currentuser = ctrl_users::GetUserDetail();
     $userid = $currentuser['userid'];
     $username = $currentuser['username'];
     $files = self::ListBackUps($userid);
     //print_r($_POST);
     foreach ($files as $file) {
         if (!fs_director::CheckForEmptyValue($controller->GetControllerRequest('FORM', 'inDelete_' . $file['backupfile'] . '')) || !fs_director::CheckForEmptyValue($controller->GetControllerRequest('FORM', 'inDelete_' . $file['backupfile'] . '_x')) || !fs_director::CheckForEmptyValue($controller->GetControllerRequest('FORM', 'inDelete_' . $file['backupfile'] . '_y'))) {
             self::ExecuteDeleteBackup($username, $file['backupfile']);
             self::$deleteok = true;
         }
     }
 }
Ejemplo n.º 16
0
 static function doForceDaemon()
 {
     global $zdbh;
     global $controller;
     runtime_csfr::Protect();
     $formvars = $controller->GetAllControllerRequests('FORM');
     if (isset($formvars['inForceFull'])) {
         $sql = $zdbh->prepare("UPDATE x_settings set so_value_tx = '0' WHERE so_name_vc = 'daemon_lastrun'");
         $sql->execute();
         $sql = $zdbh->prepare("UPDATE x_settings set so_value_tx = '0' WHERE so_name_vc = 'daemon_dayrun'");
         $sql->execute();
         $sql = $zdbh->prepare("UPDATE x_settings set so_value_tx = '0' WHERE so_name_vc = 'daemon_weekrun'");
         $sql->execute();
         $sql = $zdbh->prepare("UPDATE x_settings set so_value_tx = '0' WHERE so_name_vc = 'daemon_monthrun'");
         $sql->execute();
     }
     self::$ok = true;
 }
 /**
  * Webinterface sudo methods.
  */
 static function doCreateForwarder()
 {
     global $controller;
     runtime_csfr::Protect();
     $currentuser = ctrl_users::GetUserDetail();
     $formvars = $controller->GetAllControllerRequests('FORM');
     $keepmessage = isset($formvars['inKeepMessage']) ? fs_director::GetCheckboxValue($formvars['inKeepMessage']) : 0;
     if (self::ExecuteCreateForwarder($currentuser['userid'], $formvars['inAddress'], $formvars['inDestinationName'], $formvars['inDestinationDomain'], $keepmessage)) {
         self::$ok = true;
     }
     return true;
 }
 static function CheckCronForErrors()
 {
     global $zdbh;
     global $controller;
     $retval = FALSE;
     //Try to create the cron file if it doesnt exist...
     if (!file_exists(ctrl_options::GetSystemOption('cron_file'))) {
         fs_filehandler::UpdateFile(ctrl_options::GetSystemOption('cron_file'), 0644, "");
     }
     $currentuser = ctrl_users::GetUserDetail();
     // Check to make sure the cron is not blank before we go any further...
     if ($controller->GetControllerRequest('FORM', 'inScript') == '') {
         self::$blank = TRUE;
         $retval = TRUE;
     }
     // Check to make sure the cron script exists before we go any further...
     if (!is_file(fs_director::RemoveDoubleSlash(fs_director::ConvertSlashes(ctrl_options::GetSystemOption('hosted_dir') . $currentuser['username'] . '/public_html/' . $controller->GetControllerRequest('FORM', 'inScript'))))) {
         self::$noexists = TRUE;
         $retval = TRUE;
     }
     // Check to see if creating system cron file was successful...
     if (!is_file(ctrl_options::GetSystemOption('cron_file'))) {
         self::$cronnoexists = TRUE;
         $retval = TRUE;
     }
     // Check to makesystem cron file is writable...
     if (!is_writable(ctrl_options::GetSystemOption('cron_file'))) {
         self::$cronnowrite = TRUE;
         $retval = TRUE;
     }
     // Check to make sure the cron is not a duplicate...
     $sql = "SELECT COUNT(*) FROM x_cronjobs WHERE ct_acc_fk=:userid AND ct_script_vc=:inScript AND ct_deleted_ts IS NULL";
     $numrows = $zdbh->prepare($sql);
     $numrows->bindParam(':userid', $currentuser['userid']);
     $numrows->bindParam(':inScript', $controller->GetControllerRequest('FORM', 'inScript'));
     if ($numrows->execute()) {
         if ($numrows->fetchColumn() != 0) {
             self::$alreadyexists = TRUE;
             $retval = TRUE;
         }
     }
     return $retval;
 }
Ejemplo n.º 19
0
 static function doInstallModule()
 {
     self::$error_message = "";
     self::$error = false;
     if ($_FILES['modulefile']['error'] > 0) {
         self::$error_message = "Couldn't upload the file, " . $_FILES['modulefile']['error'] . "";
     } else {
         $archive_ext = fs_director::GetFileExtension($_FILES['modulefile']['name']);
         $module_folder = fs_director::GetFileNameNoExtentsion($_FILES['modulefile']['name']);
         $module_dir = ctrl_options::GetSystemOption('sentora_root') . 'modules/' . $module_folder;
         if (!fs_director::CheckFolderExists($module_dir)) {
             if ($archive_ext != 'zpp') {
                 self::$error_message = "Package type was not detected as a .zpp (Sentora Package) archive.";
             } else {
                 if (fs_director::CreateDirectory($module_dir)) {
                     if (sys_archive::Unzip($_FILES['modulefile']['tmp_name'], $module_dir . '/')) {
                         if (!fs_director::CheckFileExists($module_dir . '/module.xml')) {
                             self::$error_message = "No module.xml file found in the unzipped archive.";
                         } else {
                             ui_module::ModuleInfoToDB($module_folder);
                             $extra_config = $module_dir . "/deploy/install.run";
                             if (fs_director::CheckFileExists($extra_config)) {
                                 exec(ctrl_options::GetSystemOption('php_exer') . " " . $extra_config . "");
                             }
                             self::$ok = true;
                         }
                     } else {
                         self::$error_message = "Couldn't unzip the archive (" . $_FILES['modulefile']['tmp_name'] . ") to " . $module_dir . '/';
                     }
                 } else {
                     self::$error_message = "Couldn't create module folder in " . $module_dir;
                 }
             }
         } else {
             self::$error_message = "The module " . $module_folder . " is already installed on this server!";
         }
     }
     return;
 }
Ejemplo n.º 20
0
 static function ActionProcess($mode)
 {
     $currentuser = ctrl_users::GetUserDetail();
     global $controller;
     global $zdbh;
     $id = $controller->GetControllerRequest('FORM', 'inPreview');
     if ($id <= 0) {
         $id = $controller->GetControllerRequest('FORM', 'inDownload');
         $download = true;
     }
     $uid = $currentuser['userid'];
     $sql = "SELECT * FROM x_vhosts WHERE vh_acc_fk=:uid AND vh_id_pk=:id AND vh_deleted_ts IS NULL";
     $query = $zdbh->prepare($sql);
     $query->bindParam(':uid', $uid);
     $query->bindParam(':id', $id);
     $query->execute();
     if ($data = $query->fetch()) {
         switch ($mode) {
             case 'access':
                 $filepath = '/var/sentora/logs/domains/' . $currentuser['username'] . '/' . $data['vh_name_vc'] . '-access.log';
                 break;
             default:
                 $filepath = '/var/sentora/logs/domains/' . $currentuser['username'] . '/' . $data['vh_name_vc'] . '-error.log';
                 break;
         }
         self::$preview = true;
         if (file_exists($filepath)) {
             if ($download) {
                 self::downloadFile($filepath);
             } else {
                 self::$CurrentLogFile = basename($filepath);
                 self::$PreviewBuffer = self::tailCustom($filepath, self::$preview_lines);
             }
         } else {
             self::$notfile = true;
         }
     } else {
         // No domains? well something is wrong for sure
         self::$notmine = true;
     }
 }
Ejemplo n.º 21
0
 static function doDeleteDomain()
 {
     global $controller;
     runtime_csfr::Protect();
     $formvars = $controller->GetAllControllerRequests('FORM');
     if (isset($formvars['inDelete'])) {
         if (self::ExecuteDeleteDomain($formvars['inDelete'])) {
             self::$ok = TRUE;
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 22
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();
 }
Ejemplo n.º 23
0
 static function ViewErrors()
 {
     $bindlog = ctrl_options::GetSystemOption('bind_log');
     $logerror = array();
     $logwarning = array();
     $getlog = array();
     if (file_exists($bindlog)) {
         $handle = @fopen($bindlog, "r");
         $getlog = array();
         if ($handle) {
             while (!feof($handle)) {
                 $buffer = fgets($handle, 4096);
                 $getlog[] = $buffer;
                 if (strstr($buffer, 'error:') || strstr($buffer, 'error ')) {
                     $logerror[] = $buffer;
                 }
                 if (strstr($buffer, 'warning:') || strstr($buffer, 'warning ')) {
                     $logwarning[] = $buffer;
                 }
             }
             fclose($handle);
             if (!fs_director::CheckForEmptyValue($logerror)) {
                 self::$logerror = $logerror;
             }
             if (!fs_director::CheckForEmptyValue($logwarning)) {
                 self::$logwarning = $logwarning;
             }
             if (!fs_director::CheckForEmptyValue($getlog)) {
                 self::$getlog = $getlog;
             }
         }
     }
 }
Ejemplo n.º 24
0
 static function doDeleteParkedDomain()
 {
     global $controller;
     runtime_csfr::Protect();
     //        $currentuser = ctrl_users::GetUserDetail();
     $formvars = $controller->GetAllControllerRequests('FORM');
     if (isset($formvars['inDelete'])) {
         if (self::ExecuteDeleteParkedDomain($formvars['inDelete'])) {
             self::$ok = TRUE;
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 25
0
 static function CheckCreateForErrors($username, $packageid, $groupid, $email, $password = "")
 {
     global $zdbh;
     $username = strtolower(str_replace(' ', '', $username));
     // Check to make sure the username is not blank or exists before we go any further...
     if (!fs_director::CheckForEmptyValue($username)) {
         $sql = "SELECT COUNT(*) FROM x_accounts WHERE UPPER(ac_user_vc)=:user AND ac_deleted_ts IS NULL";
         $numrows = $zdbh->prepare($sql);
         $user = strtoupper($username);
         $numrows->bindParam(':user', $user);
         if ($numrows->execute()) {
             if ($numrows->fetchColumn() != 0) {
                 self::$alreadyexists = true;
                 return false;
             }
         }
         if (!self::IsValidUserName($username)) {
             self::$badname = true;
             return false;
         }
     } else {
         self::$userblank = true;
         return false;
     }
     // Check to make sure the packagename is not blank and exists before we go any further...
     if (!fs_director::CheckForEmptyValue($packageid)) {
         $sql = "SELECT COUNT(*) FROM x_packages WHERE pk_id_pk=:packageid AND pk_deleted_ts IS NULL";
         $numrows = $zdbh->prepare($sql);
         $numrows->bindParam(':packageid', $packageid);
         if ($numrows->execute()) {
             if ($numrows->fetchColumn() == 0) {
                 self::$packageblank = true;
                 return false;
             }
         }
     } else {
         self::$packageblank = true;
         return false;
     }
     // Check to make sure the groupname is not blank and exists before we go any further...
     if (!fs_director::CheckForEmptyValue($groupid)) {
         $sql = "SELECT COUNT(*) FROM x_groups WHERE ug_id_pk=:groupid";
         $numrows = $zdbh->prepare($sql);
         $numrows->bindParam(':groupid', $groupid);
         if ($numrows->execute()) {
             if ($numrows->fetchColumn() == 0) {
                 self::$groupblank = true;
                 return;
             }
         }
     } else {
         self::$groupblank = true;
         return false;
     }
     // Check for invalid characters in the email and that it exists...
     if (!fs_director::CheckForEmptyValue($email)) {
         if (!self::IsValidEmail($email)) {
             self::$bademail = true;
             return false;
         }
     } else {
         self::$emailblank = true;
         return false;
     }
     // Check that the email address is unique to the user's table
     if (!fs_director::CheckForEmptyValue($email)) {
         if (ctrl_users::CheckUserEmailIsUnique($email)) {
             self::$not_unique_email = false;
             return true;
         } else {
             self::$not_unique_email = true;
             return false;
         }
     } else {
         self::$not_unique_email = true;
         return false;
     }
     // Check for password length...
     if (!fs_director::CheckForEmptyValue($password)) {
         if (strlen($password) < ctrl_options::GetSystemOption('password_minlength')) {
             self::$badpassword = true;
             return false;
         }
     } else {
         self::$passwordblank = true;
         return false;
     }
     return true;
 }
Ejemplo n.º 26
0
 static function CheckPasswordForErrors($password)
 {
     if (!self::IsValidPassword($password)) {
         self::$badpass = true;
         return false;
     }
     return true;
 }
Ejemplo n.º 27
0
 static function DisplayUsagepChart()
 {
     global $zdbh;
     global $controller;
     $currentuser = ctrl_users::GetUserDetail();
     self::$diskquota = $currentuser['diskquota'];
     self::$diskspace = ctrl_users::GetQuotaUsages('diskspace', $currentuser['userid']);
     self::$bandwidthquota = module_controller::empty_as_0($currentuser['bandwidthquota']);
     self::$bandwidth = ctrl_users::GetQuotaUsages('bandwidth', $currentuser['userid']);
     self::$domainsquota = module_controller::empty_as_0($currentuser['domainquota']);
     self::$domains = ctrl_users::GetQuotaUsages('domains', $currentuser['userid']);
     self::$subdomainsquota = module_controller::empty_as_0($currentuser['subdomainquota']);
     self::$subdomains = ctrl_users::GetQuotaUsages('subdomains', $currentuser['userid']);
     self::$parkeddomainsquota = module_controller::empty_as_0($currentuser['parkeddomainquota']);
     self::$parkeddomains = ctrl_users::GetQuotaUsages('parkeddomains', $currentuser['userid']);
     self::$mysqlquota = module_controller::empty_as_0($currentuser['mysqlquota']);
     self::$mysql = ctrl_users::GetQuotaUsages('mysql', $currentuser['userid']);
     self::$ftpaccountsquota = module_controller::empty_as_0($currentuser['ftpaccountsquota']);
     self::$ftpaccounts = ctrl_users::GetQuotaUsages('ftpaccounts', $currentuser['userid']);
     self::$mailboxquota = module_controller::empty_as_0($currentuser['mailboxquota']);
     self::$mailboxes = ctrl_users::GetQuotaUsages('mailboxes', $currentuser['userid']);
     self::$forwardersquota = module_controller::empty_as_0($currentuser['forwardersquota']);
     self::$forwarders = ctrl_users::GetQuotaUsages('forwarders', $currentuser['userid']);
     self::$distlistsquota = $currentuser['distlistsquota'];
     self::$distlists = module_controller::empty_as_0(ctrl_users::GetQuotaUsages('distlists', $currentuser['userid']));
     $maximum = self::$diskquota;
     $used = self::$diskspace;
     if ($maximum == 0) {
         if (sys_versions::ShowOSPlatformVersion() != 'Windows') {
             // We'll specify the full path to the hsoted directory to ensure that NFS mounts etc are taken into account.
             $free = disk_free_space(ctrl_options::GetOption('hosted_dir'));
         } else {
             // On Windows we'll check the disk (partition) that is configured for the 'hostdata' directory.
             $free = disk_free_space(substr(ctrl_options::GetOption('hosted_dir'), 0, 2));
         }
         $freeLabel = fs_director::ShowHumanFileSize($free) . ' (' . ui_language::translate('Server disk') . ')';
     } else {
         $free = max($maximum - $used, 0);
         $freeLabel = fs_director::ShowHumanFileSize($free);
     }
     $usedLabel = fs_director::ShowHumanFileSize($used);
     $line = '<table class="none" cellpadding="0" cellspacing="0">' . '<tr>' . '<td align="left" valign="top" width="350px">' . '<h2>' . ui_language::translate('Disk Usage Total') . '</h2>' . '<img src="etc/lib/pChart2/MADmin/z3DPie.php?score=' . $free . '::' . $used . '&amp;imagesize=350::250&amp;chartsize=150::120&amp;radius=150' . '&amp;labels=Free_Space: ' . $freeLabel . '::Used_Space: ' . $usedLabel . '&amp;legendfont=verdana&amp;legendfontsize=8&amp;legendsize=10::220"/>' . '</td>' . '<td align="left" valign="top">' . '<h2>' . ui_language::translate('Package Usage Total') . '</h2>' . '<table class="table table-striped" border="0" cellspacing="0" cellpadding="0">' . module_controller::build_row_usage('Disk space', self::$diskspace, self::$diskquota == 0 ? -1 : self::$diskquota, true) . module_controller::build_row_usage('Bandwidth', self::$bandwidth, self::$bandwidthquota == 0 ? -1 : self::$bandwidthquota, true) . module_controller::build_row_usage('Domains', self::$domains, self::$domainsquota) . module_controller::build_row_usage('Sub-domains', self::$subdomains, self::$subdomainsquota) . module_controller::build_row_usage('Parked domains', self::$parkeddomains, self::$parkeddomainsquota) . module_controller::build_row_usage('FTP accounts', self::$ftpaccounts, self::$ftpaccountsquota) . module_controller::build_row_usage('MySQL&reg databases', self::$mysql, self::$mysqlquota) . module_controller::build_row_usage('Mailboxes', self::$mailboxes, self::$mailboxquota) . module_controller::build_row_usage('Mail forwarders', self::$forwarders, self::$forwardersquota) . module_controller::build_row_usage('Distribution lists', self::$distlists, self::$distlistsquota) . '</table>' . '</td>' . '</tr>' . '</table>';
     return $line;
 }
Ejemplo n.º 28
0
 /**
  * Webinterface sudo methods.
  */
 static function doCreateAlias()
 {
     global $controller;
     runtime_csfr::Protect();
     $currentuser = ctrl_users::GetUserDetail();
     $formvars = $controller->GetAllControllerRequests('FORM');
     if (self::ExecuteCreateAlias($currentuser['userid'], $formvars['inAddress'], $formvars['inDomain'], $formvars['inDestination'])) {
         self::$ok = true;
     }
     return true;
 }
Ejemplo n.º 29
0
 static function doCreateDefaultRecords()
 {
     global $zdbh;
     global $controller;
     runtime_csfr::Protect();
     $domainID = $controller->GetControllerRequest('FORM', 'inDomain');
     $numrows = $zdbh->prepare('SELECT * FROM x_vhosts WHERE vh_id_pk=:domainID AND vh_type_in !=2 AND vh_deleted_ts IS NULL');
     $numrows->bindParam(':domainID', $domainID);
     $numrows->execute();
     $domainName = $numrows->fetch();
     $domainName = $domainName['vh_name_vc'];
     $userID = $controller->GetControllerRequest('FORM', 'inUserID');
     if (!fs_director::CheckForEmptyValue(ctrl_options::GetSystemOption('server_ip'))) {
         $targetIP = ctrl_options::GetSystemOption('server_ip');
     } else {
         $targetIP = $_SERVER["SERVER_ADDR"];
         //This needs checking on windows 7 we may need to use LOCAL_ADDR :- Sam Mottley
     }
     //Get list of DNS rows to create
     $RowCount = $zdbh->prepare('SELECT count(*) FROM x_dns_create WHERE dc_acc_fk=:userId');
     $RowCount->bindparam(':userId', $userID);
     $RowCount->execute();
     if ($RowCount->fetchColumn() > 0) {
         //The current user have specifics entries, use them only
         $CreateList = $zdbh->prepare('SELECT * FROM x_dns_create WHERE dc_acc_fk=:userId');
         $CreateList->bindparam(':userId', $userID);
         $CreateList->execute();
     } else {
         //no entry specific to this user is present, use default entries (user number = 0)
         $CreateList = $zdbh->query('SELECT * FROM x_dns_create WHERE dc_acc_fk=0');
     }
     while ($CreateItem = $CreateList->fetch()) {
         $Target = str_replace(':IP:', $targetIP, $CreateItem['dc_target_vc']);
         $Target = str_replace(':DOMAIN:', $domainName, $Target);
         $Row = array('uid' => $userID, 'domainName' => $domainName, 'domainID' => $domainID, 'type' => $CreateItem['dc_type_vc'], 'hostName' => $CreateItem['dc_host_vc'], 'ttl' => $CreateItem['dc_ttl_in'], 'target' => $Target);
         if (!empty($CreateItem['dc_priority_in'])) {
             $Row['priority'] = $CreateItem['dc_priority_in'];
         }
         if (!empty($CreateItem['dc_weight_in'])) {
             $Row['weight'] = $CreateItem['dc_weight_in'];
         }
         if (!empty($CreateItem['dc_port_in'])) {
             $Row['port'] = $CreateItem['dc_port_in'];
         }
         self::createDNSRecord($Row);
     }
     self::$editdomain = $domainID;
     return;
 }
Ejemplo n.º 30
0
 public function UpdateClient()
 {
     $request_data = $this->XMLDataToArray($this->wsdata);
     $ctags = $request_data['xmws']['content'];
     if (!empty($ctags["whmcs_version"])) {
         $this->checkVersion($ctags["whmcs_version"]);
     }
     $response_xml = module_controller::ExecuteUpdateClient($ctags['uid'], $ctags['packageid'], '1', $ctags['groupid'], $ctags['fullname'], $ctags['email'], $ctags['address'], $ctags['postcode'], $ctags['phone'], $ctags['password']);
     if ($response_xml == true) {
         $response_xml = "success";
     } else {
         $response_xml = empty($response_xml) ? "Can't update user." : $response_xml;
     }
     $dataobject = new runtime_dataobject();
     $dataobject->addItemValue('response', '');
     $dataobject->addItemValue('content', $response_xml);
     return $dataobject->getDataObject();
 }