public static function Template()
 {
     $currentuser = ctrl_users::GetUserDetail();
     $bandwidthquota = $currentuser['bandwidthquota'];
     $bandwidth = ctrl_users::GetQuotaUsages('bandwidth', $currentuser['userid']);
     if ($bandwidthquota == 0) {
         return '<div class="progress progress-striped"><div class="progress-bar progress-bar-success" style="width: 0%"></div></div>';
     } else {
         if (fs_director::CheckForEmptyValue($bandwidth)) {
             $bandwidth = 0;
         }
         $percent = round($bandwidth / $bandwidthquota * 100, 0);
         if ($percent >= 75) {
             $bar = 'danger';
         } else {
             $bar = 'success';
         }
         if ($percent >= 10) {
             $showpercent = $percent . '%';
         } else {
             $showpercent = '';
         }
         return '<div class="progress progress-striped"><div class="progress-bar progress-bar-' . $bar . '" style="width: ' . $percent . '%">' . $showpercent . '</div></div>';
     }
 }
function DeleteApacheClientFiles()
{
    global $zdbh;
    $sql = "SELECT * FROM x_accounts WHERE ac_deleted_ts IS NOT NULL";
    $numrows = $zdbh->query($sql);
    if ($numrows->fetchColumn() != 0) {
        $sql = $zdbh->prepare($sql);
        $res = array();
        $sql->execute();
        while ($rowdeletedaccounts = $sql->fetch()) {
            // Check for an active user with same username
            $sql2 = "SELECT COUNT(*) FROM x_accounts WHERE ac_user_vc=:user AND ac_deleted_ts IS NULL";
            $numrows2 = $zdbh->prepare($sql2);
            $user = $rowdeletedaccounts['ac_user_vc'];
            $numrows2->bindParam(':user', $user);
            if ($numrows2->execute()) {
                if ($numrows2->fetchColumn() == 0) {
                    if (file_exists(ctrl_options::GetSystemOption('hosted_dir') . $rowdeletedaccounts['ac_user_vc'])) {
                        fs_director::RemoveDirectory(ctrl_options::GetSystemOption('hosted_dir') . $rowdeletedaccounts['ac_user_vc']);
                    }
                }
            }
        }
    }
}
 /**
  * Used to translate a text string into the language preference of the user.
  * @author Russell Skinner (rskinner@zpanelcp.com)
  * @global db_driver $zdbh The ZPX database handle.
  * @param $message The string to translate.
  * @return string The transalated string.
  */
 static function translate($message)
 {
     global $zdbh;
     $message = addslashes($message);
     $currentuser = ctrl_users::GetUserDetail();
     $lang = $currentuser['language'];
     $column_names = self::GetColumnNames('x_translations');
     foreach ($column_names as $column_name) {
         $columnNameClean = $zdbh->mysqlRealEscapeString($column_name);
         $sql = $zdbh->prepare("SELECT * FROM x_translations WHERE " . $columnNameClean . " LIKE :message");
         $sql->bindParam(':message', $message);
         $sql->execute();
         $result = $sql->fetch();
         if ($result) {
             if (!fs_director::CheckForEmptyValue($result['tr_' . $lang . '_tx'])) {
                 return $result['tr_' . $lang . '_tx'];
             } else {
                 return stripslashes($message);
             }
         }
     }
     if (!fs_director::CheckForEmptyValue($message) && $lang == "en") {
         $sql = $zdbh->prepare("INSERT INTO x_translations (tr_en_tx) VALUES (:message)");
         $sql->bindParam(':message', $message);
         $sql->execute();
     }
     return stripslashes($message);
 }
 public static function Template()
 {
     if (!fs_director::CheckForEmptyValue(ctrl_options::GetSystemOption('server_ip'))) {
         return ctrl_options::GetSystemOption('server_ip');
     } else {
         return sys_monitoring::ServerIPAddress();
     }
 }
 static function getDomains()
 {
     $currentuser = ctrl_users::GetUserDetail();
     $clientlist = self::ListDomains($currentuser['userid']);
     if (!fs_director::CheckForEmptyValue($clientlist)) {
         return $clientlist;
     } else {
         return false;
     }
 }
 public static function Template()
 {
     $currentuser = ctrl_users::GetUserDetail();
     if ($currentuser['bandwidthquota'] == 0) {
         $bandwidthquota = '<: Unlimited :>';
     } else {
         $bandwidthquota = fs_director::ShowHumanFileSize($currentuser['bandwidthquota']);
     }
     return $bandwidthquota;
 }
示例#7
0
 public static function Template()
 {
     $user = ctrl_users::GetUserDetail();
     if (!fs_director::CheckForEmptyValue(fs_director::CheckForEmptyValue($user['usercss']))) {
         $retval = "etc/styles/" . ui_template::GetUserTemplate() . "/css/default.css";
     } else {
         $retval = "etc/styles/" . ui_template::GetUserTemplate() . "/css/" . $user['usercss'] . ".css";
     }
     return $retval;
 }
示例#8
0
 /**
  * Returns the name (folder name) of the template that should be used for the current user.
  * @author Bobby Allen (ballen@bobbyallen.me)
  * @return string The template name.
  */
 static function GetUserTemplate()
 {
     $user = ctrl_users::GetUserDetail();
     if (fs_director::CheckForEmptyValue($user['usertheme'])) {
         # Lets use the reseller's theme they have setup!
         $reseller = ctrl_users::GetUserDetail($user['resellerid']);
         return $reseller['usertheme'];
     } else {
         return $user['usertheme'];
     }
 }
 /**
  * Gets a list of all the domains that a user has configured on their hosting account (the user id needs to be sent in the <content> tag).
  * @global type $zdbh
  * @return type 
  */
 public function GetDomainsForUser()
 {
     global $zdbh;
     $request_data = $this->RawXMWSToArray($this->wsdata);
     $response_xml = "\n";
     $alldomains = module_controller::ListDomains($request_data['content']);
     if (!fs_director::CheckForEmptyValue($alldomains)) {
         foreach ($alldomains as $domain) {
             $response_xml = $response_xml . ws_xmws::NewXMLContentSection('domain', array('id' => $domain['id'], 'uid' => $domain['uid'], 'domain' => $domain['name'], 'homedirectory' => $domain['directory'], 'active' => $domain['active']));
         }
     }
     $dataobject = new runtime_dataobject();
     $dataobject->addItemValue('response', '');
     $dataobject->addItemValue('content', $response_xml);
     return $dataobject->getDataObject();
 }
示例#10
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;
 }
示例#11
0
 /**
  * Used to translate a text string into the language preference of the user.
  * @author Pascal Peyremorte (p.peyremorte@wanadoo.fr)
  * @global db_driver $zdbh The ZPX database handle.
  * @param $message The string to translate.
  * @return string The transalated string.
  */
 static function translate($message)
 {
     global $zdbh;
     if (empty(self::$LangCol)) {
         $uid = ctrl_auth::CurrentUserID();
         $sql = $zdbh->prepare('SELECT ud_language_vc FROM x_profiles WHERE ud_user_fk=' . $uid);
         $sql->execute();
         $lang = $sql->fetch();
         self::$LangCol = 'tr_' . $lang['ud_language_vc'] . '_tx';
     }
     if (self::$LangCol == 'tr_en_tx') {
         return $message;
     }
     //no translation required, english used
     $SlashedMessage = addslashes($message);
     //protect special chars
     $sql = $zdbh->prepare('SELECT ' . self::$LangCol . ' FROM x_translations WHERE tr_en_tx =:message');
     $sql->bindParam(':message', $SlashedMessage);
     $sql->execute();
     $result = $sql->fetch();
     if ($result) {
         if (!fs_director::CheckForEmptyValue($result[self::$LangCol])) {
             return $result[self::$LangCol];
         } else {
             return $message;
         }
         //translated message empty
     } else {
         //message not found in the table
         //add unfound message to the table with empties translations
         $sql = $zdbh->prepare('INSERT INTO x_translations SET tr_en_tx=:message');
         $sql->bindParam(':message', $SlashedMessage);
         $sql->execute();
         return $message;
     }
 }
示例#12
0
 public static function Template()
 {
     $currentuser = ctrl_users::GetUserDetail();
     return fs_director::ShowHumanFileSize(ctrl_users::GetQuotaUsages('diskspace', $currentuser['userid']));
 }
示例#13
0
 /**
  * Updates an existing file and will chmod it too if required.
  * @author Bobby Allen (ballen@bobbyallen.me)
  * @param string $path The path and file name to the file to update.
  * @param string $chmod Permissions mode to use for the new file. (eg. 0777)
  * @param string $sting The content to update the file with.
  * @return boolean 
  */
 static function UpdateFile($path, $chmod = 0777, $string = "")
 {
     if (!file_exists($path)) {
         fs_filehandler::ResetFile($path);
     }
     $fp = @fopen($path, 'w');
     @fwrite($fp, $string);
     @fclose($fp);
     fs_director::SetFileSystemPermissions($path, $chmod);
     return true;
 }
示例#14
0
 static function getResult()
 {
     if (!fs_director::CheckForEmptyValue(self::$blank)) {
         return ui_sysmessage::shout(ui_language::translate("You must enter a valid username and password to create your FTP account."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$alreadyexists)) {
         return ui_sysmessage::shout(ui_language::translate("An FTP account with that name already exists."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$error)) {
         return ui_sysmessage::shout(ui_language::translate("There was an error updating your FTP accounts."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$badname)) {
         return ui_sysmessage::shout(ui_language::translate("Your ftp account name is not valid. Please enter a valid ftp account name."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$invalidPath)) {
         return ui_sysmessage::shout(ui_language::translate("Invalid Folder."), "zannounceok");
     }
     if (!fs_director::CheckForEmptyValue(self::$ok)) {
         return ui_sysmessage::shout(ui_language::translate("FTP accounts updated successfully."), "zannounceok");
     }
     return;
 }
示例#15
0
 static function fileExists($combinedPath)
 {
     if (!fs_director::CheckFileExists($combinedPath)) {
         self::setFlashMessage('debug', 'file does not exist');
         return false;
     }
     self::setFlashMessage('debug', 'file exists');
     return true;
 }
 static function getResult()
 {
     if (!fs_director::CheckForEmptyValue(self::$ResultOk)) {
         return ui_sysmessage::shout(ui_language::translate(self::$ResultOk), 'zannouncesuccess', 'SUCCESS DNS SAVED');
     } elseif (!fs_director::CheckForEmptyValue(self::$ResultErr)) {
         return ui_sysmessage::shout(ui_language::translate(self::$ResultErr), 'zannounceerror', 'ERROR DNS NOT SAVED');
     }
     return;
 }
示例#17
0
    $numrows->bindParam(':dl_address_vc', $rowdl['dl_address_vc']);
    $numrows->execute();
    $result = $numrows->fetch();
    if ($result) {
        //echo $rowdlu['du_address_vc'];
        $newlist = str_replace("," . $rowdlu['du_address_vc'], "", $result['goto']);
        $newlist = str_replace(",,", ",", $newlist);
        $sql = "UPDATE alias SET goto=:newlist, modified=NOW() WHERE address=:dl_address_vc";
        $sql = $mail_db->prepare($sql);
        $sql->bindParam(':newlist', $newlist);
        $sql->bindParam(':dl_address_vc', $rowdl['dl_address_vc']);
        $sql->execute();
    }
}
// Adding Postfix Distubution List User
if (!fs_director::CheckForEmptyValue(self::$createuser)) {
    //$result = $mail_db->query("SELECT * FROM alias WHERE address='" . $rowdl['dl_address_vc'] . "'")->Fetch();
    $numrows = $mail_db->prepare("SELECT * FROM alias WHERE address=:dl_address_vc");
    $numrows->bindParam(':dl_address_vc', $rowdl['dl_address_vc']);
    $numrows->execute();
    $result = $numrows->fetch();
    if ($result) {
        $newlist = $result['goto'] . "," . $fulladdress;
        $newlist = str_replace(",,", ",", $newlist);
        $sql = "UPDATE alias SET goto=:newlist, modified=NOW() WHERE address=:dl_address_vc";
        $sql = $mail_db->prepare($sql);
        $sql->bindParam(':newlist', $newlist);
        $sql->bindParam(':dl_address_vc', $rowdl['dl_address_vc']);
        $sql->execute();
    }
}
 static function getResult()
 {
     if (!fs_director::CheckForEmptyValue(self::$blank)) {
         return ui_sysmessage::shout(ui_language::translate("<strong>Error:</strong> You need to specify a valid location for your script."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$noexists)) {
         return ui_sysmessage::shout(ui_language::translate("<strong>Error:</strong> Your script does not appear to exist at that location."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$cronnoexists)) {
         return ui_sysmessage::shout(ui_language::translate("<strong>Error:</strong> System Cron file could not be created."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$cronnowrite)) {
         return ui_sysmessage::shout(ui_language::translate("<strong>Error:</strong> Could not write to the System Cron file."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$alreadyexists)) {
         return ui_sysmessage::shout(ui_language::translate("<strong>Error:</strong> You can not add the same cron task more than once."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$error)) {
         return ui_sysmessage::shout(ui_language::translate("<strong>Error:</strong> There was an error updating the cron job."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$ok)) {
         return ui_sysmessage::shout(ui_language::translate("<strong>Success:</strong> Cron updated successfully."), "zannounceok");
     }
     return;
 }
 /**
  * Returns a nice human readable copy of the server uptime.
  * @author Bobby Allen (ballen@bobbyallen.me)
  * @return string Human readable server uptime.
  */
 static function ServerUptime()
 {
     if (sys_versions::ShowOSPlatformVersion() == "Linux") {
         $uptime = trim(exec("cat /proc/uptime"));
         $uptime = explode(" ", $uptime);
         $uptime = $uptime[0];
         $day = 86400;
         $days = floor($uptime / $day);
         $utdelta = $uptime - $days * $day;
         $hour = 3600;
         $hours = floor($utdelta / $hour);
         $utdelta -= $hours * $hour;
         $minute = 60;
         $minutes = floor($utdelta / $minute);
         $days = fs_director::CheckForNullValue($days != 1, $days . ' days', $days . ' day');
         $hours = fs_director::CheckForNullValue($hours != 1, $hours . ' hours', $hours . ' hour');
         $minutes = fs_director::CheckForNullValue($minutes != 1, $minutes . ' minutes', $minutes . ' minute');
         $retval = $days . ", " . $hours . ", " . $minutes . "";
     } elseif (sys_versions::ShowOSPlatformVersion() == "Windows") {
         $pagefile = "C:\\pagefile.sys";
         $upsince = filemtime($pagefile);
         $gettime = time() - filemtime($pagefile);
         $days = floor($gettime / (24 * 3600));
         $gettime = $gettime - $days * (24 * 3600);
         $hours = floor($gettime / 3600);
         $gettime = $gettime - $hours * 3600;
         $minutes = floor($gettime / 60);
         $gettime = $gettime - $minutes * 60;
         $seconds = $gettime;
         $days = fs_director::CheckForNullValue($days != 1, $days . ' days', $days . ' day');
         $hours = fs_director::CheckForNullValue($hours != 1, $hours . ' hours', $hours . ' hour');
         $minutes = fs_director::CheckForNullValue($minutes != 1, $minutes . ' minutes', $minutes . ' minute');
         $retval = $days . ", " . $hours . ", " . $minutes . "";
     } elseif (sys_versions::ShowOSPlatformVersion() == "MacOSX") {
         $uptime = explode(" ", exec("sysctl -n kern.boottime"));
         $uptime = str_replace(",", "", $uptime[3]);
         $uptime = time() - $uptime;
         $min = $uptime / 60;
         $hours = $min / 60;
         $days = floor($hours / 24);
         $hours = floor($hours - $days * 24);
         $minutes = floor($min - $days * 60 * 24 - $hours * 60);
         $days = fs_director::CheckForNullValue($days != 1, $days . ' days', $days . ' day');
         $hours = fs_director::CheckForNullValue($hours != 1, $hours . ' hours', $hours . ' hour');
         $minutes = fs_director::CheckForNullValue($minutes != 1, $minutes . ' minutes', $minutes . ' minute');
         $retval = $days . ", " . $hours . ", " . $minutes . "";
     } elseif (sys_versions::ShowOSPlatformVersion() == "FreeBSD") {
         $uptime = explode(" ", exec("/sbin/sysctl -n kern.boottime"));
         $uptime = str_replace(",", "", $uptime[3]);
         $uptime = time() - $uptime;
         $min = $uptime / 60;
         $hours = $min / 60;
         $days = floor($hours / 24);
         $hours = floor($hours - $days * 24);
         $minutes = floor($min - $days * 60 * 24 - $hours * 60);
         $days = fs_director::CheckForNullValue($days != 1, $days . ' days', $days . ' day');
         $hours = fs_director::CheckForNullValue($hours != 1, $hours . ' hours', $hours . ' hour');
         $minutes = fs_director::CheckForNullValue($minutes != 1, $minutes . ' minutes', $minutes . ' minute');
         $retval = $days . ", " . $hours . ", " . $minutes . "";
     } else {
         $retval = "Unsupported OS";
     }
     return $retval;
 }
示例#20
0
        $sql->execute();
        $sql = $mail_db->prepare("INSERT INTO alias  (address,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t \tgoto,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t \tdomain,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcreated,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t \tmodified,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t \tactive) VALUES (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t:fulladdress,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t:fulladdress2,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t:domain,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t \tNOW(),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t \tNOW(),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t'1')");
        $sql->bindParam(':domain', $domain);
        $sql->bindParam(':fulladdress', $fulladdress);
        $sql->bindParam(':fulladdress2', $fulladdress);
        $sql->execute();
    }
}
// Deleting PostFix Mailboxes
if (!fs_director::CheckForEmptyValue(self::$delete)) {
    $sql = $mail_db->prepare("DELETE FROM mailbox WHERE username=:mb_address_vc");
    $sql->bindParam(':mb_address_vc', $rowmailbox['mb_address_vc']);
    $sql->execute();
    $sql = $mail_db->prepare("DELETE FROM alias WHERE address=:mb_address_vc");
    $sql->bindParam(':mb_address_vc', $rowmailbox['mb_address_vc']);
    $sql->execute();
}
//Saving PostFix Mailboxes
if (!fs_director::CheckForEmptyValue(self::$update)) {
    if (!fs_director::CheckForEmptyValue($password)) {
        $sql = $mail_db->prepare("UPDATE mailbox SET password=:password, modified=NOW() WHERE username=:mb_address_vc");
        $password = '******' . md5($password);
        $sql->bindParam(':password', $password);
        $sql->bindParam(':mb_address_vc', $rowmailbox['mb_address_vc']);
        $sql->execute();
    }
    $sql = $mail_db->prepare("UPDATE mailbox SET active=:enabled, modified=NOW() WHERE username=:mb_address_vc");
    $sql->bindParam(':enabled', $enabled);
    $sql->bindParam(':mb_address_vc', $rowmailbox['mb_address_vc']);
    $sql->execute();
}
示例#21
0
 static function getResult()
 {
     if (!fs_director::CheckForEmptyValue(self::$notmine)) {
         return ui_sysmessage::shout(ui_language::translate("Unable to get log preview, this domain does not belong to you."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$notfile)) {
         return ui_sysmessage::shout(ui_language::translate("The log does not exit yet."), "zannounceerror");
     }
     return;
 }
示例#22
0
 static function getResult()
 {
     if (!fs_director::CheckForEmptyValue(self::$blank)) {
         return ui_sysmessage::shout(ui_language::translate("Your Domain can not be empty. Please enter a valid Domain Name and try again."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$badname)) {
         return ui_sysmessage::shout(ui_language::translate("Your Domain name is not valid. Please enter a valid Domain Name: i.e. 'domain.com'"), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$alreadyexists)) {
         return ui_sysmessage::shout(ui_language::translate("The domain already appears to exist on this server."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$nosub)) {
         return ui_sysmessage::shout(ui_language::translate("You cannot add a Sub-Domain here. Please use the Subdomain manager to add Sub-Domains."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$error)) {
         return ui_sysmessage::shout(ui_language::translate("Please remove 'www'. The 'www' will automatically work with all Domains / Subdomains."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$writeerror)) {
         return ui_sysmessage::shout(ui_language::translate("There was a problem writting to the virtual host container file. Please contact your administrator and report this error. Your domain will not function until this error is corrected."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$ok)) {
         return ui_sysmessage::shout(ui_language::translate("Changes to your domain web hosting has been saved successfully."), "zannounceok");
     }
     return;
 }
示例#23
0
 static function getResult()
 {
     if (!fs_director::CheckForEmptyValue(self::$userblank)) {
         return ui_sysmessage::shout(ui_language::translate("You need to specify a username to create a new client."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$emailblank)) {
         return ui_sysmessage::shout(ui_language::translate("You need to specify an email address to create a new client."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$passwordblank)) {
         return ui_sysmessage::shout(ui_language::translate("Your password cannot be blank."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$packageblank)) {
         return ui_sysmessage::shout(ui_language::translate("You must select a package for your new client."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$groupblank)) {
         return ui_sysmessage::shout(ui_language::translate("You must select a user group for your new client."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$badname)) {
         return ui_sysmessage::shout(ui_language::translate("Your client name is not valid. Please enter a valid client name."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$bademail)) {
         return ui_sysmessage::shout(ui_language::translate("Your email adress is not valid. Please enter a valid email address."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$badpassword)) {
         return ui_sysmessage::shout(ui_language::translate("Your password did not meet the minimun length requirements. Characters needed for password length") . ": " . ctrl_options::GetSystemOption('password_minlength'), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$alreadyexists)) {
         return ui_sysmessage::shout(ui_language::translate("A client with that name already appears to exsist on this server."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$ok)) {
         return ui_sysmessage::shout(ui_language::translate("Changes to your client(s) have been saved successfully!"), "zannounceok");
     }
     if (!fs_director::CheckForEmptyValue(self::$not_unique_email)) {
         return ui_sysmessage::shout(ui_language::translate("Another user account is already using this email address."), "zannounceerror");
     }
     return;
 }
 static function getResult()
 {
     if (!fs_director::CheckForEmptyValue(self::$alreadyexistssame)) {
         return ui_sysmessage::shout(ui_language::translate("You cannot forward a mailbox to itself!"), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$alreadyexists)) {
         return ui_sysmessage::shout(ui_language::translate('A mailbox, alias, forwarder or distribution list already exists with that name.'), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$validemail)) {
         return ui_sysmessage::shout(ui_language::translate("Your email address is not valid."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$password)) {
         return ui_sysmessage::shout(ui_language::translate("Your password cannot be blank."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$noaddress)) {
         return ui_sysmessage::shout(ui_language::translate("Your email address cannot be blank."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$ok)) {
         return ui_sysmessage::shout(ui_language::translate("Changes to your forwarders have been saved successfully!"), "zannounceok");
     } else {
         return NULL;
     }
     return;
 }
示例#25
0
 static function DisplaypBar($total, $quota)
 {
     $currentuser = ctrl_users::GetUserDetail();
     $typequota = $currentuser[$quota];
     $type = ctrl_users::GetQuotaUsages($total, $currentuser['userid']);
     if ($typequota == 0) {
         return '';
     }
     //Quota are disabled
     if (fs_director::CheckForEmptyValue($type)) {
         return '<img src="etc/lib/pChart2/MADmin/zProgress.php?percent=0"/>';
     }
     if ($type == $typequota) {
         return '<img src="etc/lib/pChart2/MADmin/zProgress.php?percent=100"/>';
     }
     return '<img src="etc/lib/pChart2/MADmin/zProgress.php?percent=' . round($type / $typequota * 100, 0) . '"/>';
 }
示例#26
0
 static function getResult()
 {
     if (!fs_director::CheckForEmptyValue(self::$ok)) {
         return ui_sysmessage::shout(ui_language::translate("Changes to your settings have been saved successfully!"));
     }
     return;
 }
 static function getResult()
 {
     if (!fs_director::CheckForEmptyValue(self::$ok)) {
         return ui_sysmessage::shout(ui_language::translate("Changes to your settings have been saved successfully!"), "zannounceok");
     }
     if (!fs_director::CheckForEmptyValue(self::$notwritable)) {
         return ui_sysmessage::shout(ui_language::translate("No permission to write to log file."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$forceupdate)) {
         return ui_sysmessage::shout(ui_language::translate("All zone records will be updated on next daemon run."), "zannounceok");
     }
     if (!fs_director::CheckForEmptyValue(self::$reset)) {
         return ui_sysmessage::shout(number_format(self::$reset) . " " . ui_language::translate("Domains records where reset to default"), "zannounceok");
     }
     if (!fs_director::CheckForEmptyValue(self::$addmissing)) {
         return ui_sysmessage::shout(number_format(self::$addmissing) . " " . ui_language::translate("Domains records were created"), "zannounceok");
     }
     if (!fs_director::CheckForEmptyValue(self::$deletedtype)) {
         return ui_sysmessage::shout(number_format(self::$deletedtype) . " '" . self::$type . "' " . ui_language::translate("Records where marked as deleted from the database"), "zannounceok");
     }
     if (!fs_director::CheckForEmptyValue(self::$deleted)) {
         return ui_sysmessage::shout(number_format(self::$deleted) . " " . ui_language::translate("Records where marked as deleted from the database"), "zannounceok");
     }
     if (!fs_director::CheckForEmptyValue(self::$purged)) {
         return ui_sysmessage::shout(number_format(self::$purged) . " " . ui_language::translate("Records where purged from the database"), "zannounceok");
     }
     return;
 }
示例#28
0
function WriteDNSNamedHook()
{
    global $zdbh;
    $domains = array();
    //Get all the domain ID's we need and put them in an array.
    $sql = "SELECT COUNT(*) FROM x_dns WHERE dn_deleted_ts IS NULL";
    if ($numrows = $zdbh->query($sql)) {
        if ($numrows->fetchColumn() != 0) {
            $sql = $zdbh->prepare("SELECT * FROM x_dns WHERE dn_deleted_ts IS NULL GROUP BY dn_vhost_fk");
            $sql->execute();
            while ($rowdns = $sql->fetch()) {
                $domains[] = $rowdns['dn_name_vc'];
            }
        }
    }
    // Create named directory if it doesnt exists...
    if (!is_dir(ctrl_options::GetSystemOption('named_dir'))) {
        fs_director::CreateDirectory(ctrl_options::GetSystemOption('named_dir'));
        fs_director::SetFileSystemPermissions(ctrl_options::GetSystemOption('named_dir'));
    }
    $named_file = ctrl_options::GetSystemOption('named_dir') . ctrl_options::GetSystemOption('named_conf');
    echo "Updating " . $named_file . fs_filehandler::NewLine();
    // Now we have all domain ID's, loop through them and find records for each zone file.
    $line = "";
    foreach ($domains as $domain) {
        echo "CHECKING ZONE FILE: " . ctrl_options::GetSystemOption('zone_dir') . $domain . ".txt..." . fs_filehandler::NewLine();
        $command = ctrl_options::GetSystemOption('named_checkzone');
        $args = array($domain, ctrl_options::GetSystemOption('zone_dir') . $domain . ".txt");
        $retval = ctrl_system::systemCommand($command, $args);
        if ($retval == 0) {
            echo "Syntax check passed. Adding zone to " . ctrl_options::GetSystemOption('named_conf') . fs_filehandler::NewLine();
            $line .= "zone \"" . $domain . "\" IN {" . fs_filehandler::NewLine();
            $line .= "\ttype master;" . fs_filehandler::NewLine();
            $line .= "\tfile \"" . ctrl_options::GetSystemOption('zone_dir') . $domain . ".txt\";" . fs_filehandler::NewLine();
            $line .= "\tallow-transfer { " . ctrl_options::GetSystemOption('allow_xfer') . "; };" . fs_filehandler::NewLine();
            $line .= "};" . fs_filehandler::NewLine();
        } else {
            echo "Syntax ERROR. Skipping zone record." . fs_filehandler::NewLine();
        }
    }
    fs_filehandler::UpdateFile($named_file, 0777, $line);
}
示例#29
0
function BackupVhostConfigFile()
{
    echo "Apache VHost backups are enabled... Backing up current vhost.conf to: " . ctrl_options::GetSystemOption('apache_budir') . fs_filehandler::NewLine();
    if (!is_dir(ctrl_options::GetSystemOption('apache_budir'))) {
        fs_director::CreateDirectory(ctrl_options::GetSystemOption('apache_budir'));
    }
    copy(ctrl_options::GetSystemOption('apache_vhost'), ctrl_options::GetSystemOption('apache_budir') . "VHOST_BACKUP_" . time());
    fs_director::SetFileSystemPermissions(ctrl_options::GetSystemOption('apache_budir') . ctrl_options::GetSystemOption('apache_vhost') . ".BU", 0777);
    if (ctrl_options::GetSystemOption('apache_purgebu') == strtolower("true")) {
        echo "Apache VHost purges are enabled... Purging backups older than: " . ctrl_options::GetSystemOption('apache_purge_date') . " days..." . fs_filehandler::NewLine();
        echo "[FILE][PURGE_DATE][FILE_DATE][ACTION]" . fs_filehandler::NewLine();
        $purge_date = ctrl_options::GetSystemOption('apache_purge_date');
        if ($handle = @opendir(ctrl_options::GetSystemOption('apache_budir'))) {
            while (false !== ($file = readdir($handle))) {
                if ($file != "." && $file != "..") {
                    $filetime = @filemtime(ctrl_options::GetSystemOption('apache_budir') . $file);
                    if ($filetime == NULL) {
                        $filetime = @filemtime(utf8_decode(ctrl_options::GetSystemOption('apache_budir') . $file));
                    }
                    $filetime = floor((time() - $filetime) / 86400);
                    echo $file . " - " . $purge_date . " - " . $filetime . "";
                    if ($purge_date < $filetime) {
                        //delete the file
                        echo " - Deleting file..." . fs_filehandler::NewLine();
                        unlink(ctrl_options::GetSystemOption('apache_budir') . $file);
                    } else {
                        echo " - Skipping file..." . fs_filehandler::NewLine();
                    }
                }
            }
        }
        echo "Purging old backups complete..." . fs_filehandler::NewLine();
    }
    echo "Apache backups complete..." . fs_filehandler::NewLine();
}
示例#30
0
function ExecuteBackup($userid, $username, $download = 0)
{
    include '../../../cnf/db.php';
    try {
        $zdbh = new db_driver("mysql:host=" . $host . ";dbname=" . $dbname . "", $user, $pass);
    } catch (PDOException $e) {
        exit;
    }
    $basedir = ctrl_options::GetSystemOption('temp_dir');
    if (!is_dir($basedir)) {
        fs_director::CreateDirectory($basedir);
    }
    $basedir = ctrl_options::GetSystemOption('sentora_root') . "etc/tmp/";
    if (!is_dir($basedir)) {
        fs_director::CreateDirectory($basedir);
    }
    $temp_dir = ctrl_options::GetSystemOption('sentora_root') . "etc/tmp/";
    // Lets grab and archive the user's web data....
    $homedir = ctrl_options::GetSystemOption('hosted_dir') . $username;
    $backupname = $username . "_" . date("M-d-Y_hms", time());
    $dbstamp = date("dmy_Gi", time());
    // We now see what the OS is before we work out what compression command to use..
    if (sys_versions::ShowOSPlatformVersion() == "Windows") {
        $resault = exec(fs_director::SlashesToWin(ctrl_options::GetSystemOption('zip_exe') . " a -tzip -y-r " . $temp_dir . $backupname . ".zip " . $homedir . "/public_html"));
    } else {
        //cd /var/sentora/hostdata/zadmin/; zip -r backups/backup.zip public_html/
        $resault = exec("cd " . $homedir . "/ && " . ctrl_options::GetSystemOption('zip_exe') . " -r9 " . $temp_dir . $backupname . " public_html/*");
        @chmod($temp_dir . $backupname . ".zip", 0777);
    }
    // Now lets backup all MySQL datbases for the user and add them to the archive...
    $sql = "SELECT COUNT(*) FROM x_mysql_databases WHERE my_acc_fk=:userid AND my_deleted_ts IS NULL";
    $numrows = $zdbh->prepare($sql);
    $numrows->bindParam(':userid', $userid);
    $numrows->execute();
    if ($numrows) {
        if ($numrows->fetchColumn() != 0) {
            $sql = $zdbh->prepare("SELECT * FROM x_mysql_databases WHERE my_acc_fk=:userid AND my_deleted_ts IS NULL");
            $sql->bindParam(':userid', $userid);
            $sql->execute();
            while ($row_mysql = $sql->fetch()) {
                $bkcommand = ctrl_options::GetSystemOption('mysqldump_exe') . " -h " . $host . " -u " . $user . " -p" . $pass . " --no-create-db " . $row_mysql['my_name_vc'] . " > " . $temp_dir . $row_mysql['my_name_vc'] . "_" . $dbstamp . ".sql";
                passthru($bkcommand);
                // Add it to the ZIP archive...
                if (sys_versions::ShowOSPlatformVersion() == "Windows") {
                    $resault = exec(fs_director::SlashesToWin(ctrl_options::GetSystemOption('zip_exe') . " u " . $temp_dir . $backupname . ".zip " . $temp_dir . $row_mysql['my_name_vc'] . "_" . $dbstamp . ".sql"));
                } else {
                    $resault = exec("cd " . $temp_dir . "/ && " . ctrl_options::GetSystemOption('zip_exe') . " " . $temp_dir . $backupname . "  " . $row_mysql['my_name_vc'] . "_" . $dbstamp . ".sql");
                }
                unlink($temp_dir . $row_mysql['my_name_vc'] . "_" . $dbstamp . ".sql");
            }
        }
    }
    // We have the backup now lets output it to disk or download
    if (file_exists($temp_dir . $backupname . ".zip")) {
        // If Disk based backups are allowed in backup config
        if (strtolower(ctrl_options::GetSystemOption('disk_bu')) == "true") {
            // Copy Backup to user home directory...
            $backupdir = $homedir . "/backups/";
            if (!is_dir($backupdir)) {
                fs_director::CreateDirectory($backupdir);
                @chmod($backupdir, 0777);
            }
            copy($temp_dir . $backupname . ".zip", $backupdir . $backupname . ".zip");
            fs_director::SetFileSystemPermissions($backupdir . $backupname . ".zip", 0777);
        } else {
            $backupdir = $temp_dir;
        }
        // If Client has checked to download file
        if ($download != 0) {
            /* Ajax not supporting headers - changed to link in temp dir.
                          if (sys_versions::ShowOSPlatformVersion() == "Windows") {
                          # Now we send the output (Windows)...
                          header('Pragma: public');
                          header('Expires: 0');
                          header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
                          header('Cache-Control: private', false);
                          header('Content-Type: application/zip');
                          header('Content-Disposition: attachment; filename=' . $backupname . '.zip');
                          header('Content-Transfer-Encoding: binary');
                          header('Content-Length: ' . filesize($backupdir . $backupname . '.zip ') . '');
                          readfile($backupdir . $backupname . ".zip ");
                          } else {
            
                          # Now we send the output (POSIX)...
                          $file = $backupdir . $backupname . ".zip";
                          header('Pragma: public');
                          header('Expires: 0');
                          header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
                          header('Cache-Control: private', false);
                          header('Content-Description: File Transfer');
                          header('Content-Transfer-Encoding: binary');
                          header('Content-Type: application/force-download');
                          header('Content-Length: ' . filesize($file));
                          header('Content-Disposition: attachment; filename=' . $backupname . '.zip');
                          readfile_chunked($file);
                          }
                         */
            fs_director::SetFileSystemPermissions($backupdir . $backupname . ".zip", 0777);
            return $temp_dir . $backupname . ".zip";
        }
        unlink($temp_dir . $backupname . ".zip");
    } else {
        echo "File not found in temp directory!";
        return FALSE;
    }
    return TRUE;
}