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>';
     }
 }
 /**
  * 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);
 }
예제 #3
0
 public static function Template()
 {
     if (!fs_director::CheckForEmptyValue(ctrl_options::GetSystemOption('server_ip'))) {
         return ctrl_options::GetSystemOption('server_ip');
     } else {
         return sys_monitoring::ServerIPAddress();
     }
 }
예제 #4
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;
 }
 static function getDomains()
 {
     $currentuser = ctrl_users::GetUserDetail();
     $clientlist = self::ListDomains($currentuser['userid']);
     if (!fs_director::CheckForEmptyValue($clientlist)) {
         return $clientlist;
     } else {
         return false;
     }
 }
예제 #6
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();
 }
예제 #8
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;
 }
예제 #9
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;
     }
 }
 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;
 }
예제 #11
0
 static function getResult()
 {
     if (!fs_director::CheckForEmptyValue(self::$filenotexist)) {
         return ui_sysmessage::shout("There was an error saving your backup!", "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$deleteok)) {
         return ui_sysmessage::shout("Backup deleted successfully!", "zannounceok");
     }
     if (!fs_director::CheckForEmptyValue(self::$backupok)) {
         return ui_sysmessage::shout("Backup completed successfully!", "zannounceok");
     }
     return;
 }
예제 #12
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;
 }
예제 #13
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;
 }
function WriteVhostConfigFile()
{
    global $zdbh;
    //Get email for server admin of zpanel
    $getserveremail = $zdbh->query("SELECT ac_email_vc FROM x_accounts where ac_id_pk=1")->fetch();
    if ($getserveremail['ac_email_vc'] != "") {
        $serveremail = $getserveremail['ac_email_vc'];
    } else {
        $serveremail = "postmaster@" . ctrl_options::GetSystemOption('zpanel_domain');
    }
    $customPorts = array();
    $portQuery = $zdbh->prepare("SELECT vh_custom_port_in, vh_deleted_ts FROM zpanel_core.x_vhosts WHERE vh_custom_port_in IS NOT NULL AND vh_deleted_ts IS NULL");
    $portQuery->execute();
    while ($rowport = $portQuery->fetch()) {
        $customPorts[] = $rowport['vh_custom_port_in'];
    }
    $customPortList = array_unique($customPorts);
    /*
     * ###########################################################################​###################################
     * #
     * # Default Virtual Host Container
     * #
     * ###########################################################################​###################################
     */
    $line = "################################################################" . fs_filehandler::NewLine();
    $line .= "# Apache VHOST configuration file" . fs_filehandler::NewLine();
    $line .= "# Automatically generated by ZPanel " . sys_versions::ShowZpanelVersion() . fs_filehandler::NewLine();
    $line .= "# Generated on: " . date(ctrl_options::GetSystemOption('zpanel_df'), time()) . fs_filehandler::NewLine();
    $line .= "################################################################" . fs_filehandler::NewLine();
    $line .= "" . fs_filehandler::NewLine();
    /**
     * NameVirtualHost is still needed for Apache 2.2
     * @todo conditionally run this for apache version > 2.2
     * warning apache verion not available in php functions when running over cli
     */
    $line .= "NameVirtualHost *:" . ctrl_options::GetSystemOption('apache_port') . "" . fs_filehandler::NewLine();
    foreach ($customPortList as $port) {
        $line .= "NameVirtualHost *:" . $port . "" . fs_filehandler::NewLine();
    }
    $line .= "" . fs_filehandler::NewLine();
    $line .= "# Configuration for ZPanel control panel." . fs_filehandler::NewLine();
    $line .= "<VirtualHost *:" . ctrl_options::GetSystemOption('sentora_port') . ">" . fs_filehandler::NewLine();
    $line .= "ServerAdmin " . $serveremail . fs_filehandler::NewLine();
    $line .= "DocumentRoot \"" . ctrl_options::GetSystemOption('zpanel_root') . "\"" . fs_filehandler::NewLine();
    $line .= "ServerName " . ctrl_options::GetSystemOption('zpanel_domain') . "" . fs_filehandler::NewLine();
    $line .= "AddType application/x-httpd-php .php" . fs_filehandler::NewLine();
    $line .= "<Directory \"" . ctrl_options::GetSystemOption('zpanel_root') . "\">" . fs_filehandler::NewLine();
    $line .= "Options +FollowSymLinks -Indexes" . fs_filehandler::NewLine();
    $line .= "    AllowOverride All" . fs_filehandler::NewLine();
    $line .= "    Order allow,deny" . fs_filehandler::NewLine();
    $line .= "    Allow from all" . fs_filehandler::NewLine();
    $line .= "</Directory>" . fs_filehandler::NewLine();
    $line .= "" . fs_filehandler::NewLine();
    $line .= "# Custom settings are loaded below this line (if any exist)" . fs_filehandler::NewLine();
    // Global custom zpanel entry
    $line .= ctrl_options::GetSystemOption('global_zpcustom') . fs_filehandler::NewLine();
    $line .= "</VirtualHost>" . fs_filehandler::NewLine();
    $line .= "" . fs_filehandler::NewLine();
    $line .= "################################################################" . fs_filehandler::NewLine();
    $line .= "# ZPanel generated VHOST configurations below....." . fs_filehandler::NewLine();
    $line .= "################################################################" . fs_filehandler::NewLine();
    $line .= "" . fs_filehandler::NewLine();
    /*
     * ##############################################################################################################
     * #
     * # All Virtual Host Containers
     * #
     * ##############################################################################################################
     */
    // Zpanel virtual host container configuration
    $sql = $zdbh->prepare("SELECT * FROM x_vhosts WHERE vh_deleted_ts IS NULL");
    $sql->execute();
    while ($rowvhost = $sql->fetch()) {
        // Grab some variables we will use for later...
        $vhostuser = ctrl_users::GetUserDetail($rowvhost['vh_acc_fk']);
        $bandwidth = ctrl_users::GetQuotaUsages('bandwidth', $vhostuser['userid']);
        $diskspace = ctrl_users::GetQuotaUsages('diskspace', $vhostuser['userid']);
        // Set the vhosts to "LIVE"
        $vsql = $zdbh->prepare("UPDATE x_vhosts SET vh_active_in=1 WHERE vh_id_pk=:id");
        $vsql->bindParam(':id', $rowvhost['vh_id_pk']);
        $vsql->execute();
        // Add a default email if no email found for client.
        if (fs_director::CheckForEmptyValue($vhostuser['email'])) {
            $useremail = "postmaster@" . $rowvhost['vh_name_vc'];
        } else {
            $useremail = $vhostuser['email'];
        }
        // Check if domain or subdomain to see if we add an alias with 'www'
        if ($rowvhost['vh_type_in'] == 2) {
            $serveralias = $rowvhost['vh_name_vc'];
        } else {
            $serveralias = $rowvhost['vh_name_vc'] . " www." . $rowvhost['vh_name_vc'];
        }
        if (fs_director::CheckForEmptyValue($rowvhost['vh_custom_port_in'])) {
            $vhostPort = ctrl_options::GetSystemOption('apache_port');
        } else {
            $vhostPort = $rowvhost['vh_custom_port_in'];
        }
        if (fs_director::CheckForEmptyValue($rowvhost['vh_custom_ip_vc'])) {
            $vhostIp = "*";
        } else {
            $vhostIp = $rowvhost['vh_custom_ip_vc'];
        }
        //Domain is enabled
        //Line1: Domain enabled - Client also is enabled.
        //Line2: Domain enabled - Client may be disabled, but 'Allow Disabled' = 'true' in apache settings.
        if ($rowvhost['vh_enabled_in'] == 1 && ctrl_users::CheckUserEnabled($rowvhost['vh_acc_fk']) || $rowvhost['vh_enabled_in'] == 1 && ctrl_options::GetSystemOption('apache_allow_disabled') == strtolower("true")) {
            /*
             * ##################################################
             * #
             * # Disk Quotas Check
             * #
             * ##################################################
             */
            //Domain is beyond its diskusage
            if ($vhostuser['diskquota'] != 0 && $diskspace > $vhostuser['diskquota']) {
                $line .= "# DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
                $line .= "# THIS DOMAIN HAS BEEN DISABLED FOR QUOTA OVERAGE" . fs_filehandler::NewLine();
                $line .= "<virtualhost " . $vhostIp . ":" . $vhostPort . ">" . fs_filehandler::NewLine();
                $line .= "ServerName " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
                $line .= "ServerAlias " . $rowvhost['vh_name_vc'] . " www." . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
                $line .= "ServerAdmin " . $useremail . fs_filehandler::NewLine();
                $line .= "DocumentRoot \"" . ctrl_options::GetSystemOption('static_dir') . "diskexceeded\"" . fs_filehandler::NewLine();
                $line .= "<Directory />" . fs_filehandler::NewLine();
                $line .= "  Options +FollowSymLinks -Indexes" . fs_filehandler::NewLine();
                $line .= "  AllowOverride All" . fs_filehandler::NewLine();
                $line .= "  Order Allow,Deny" . fs_filehandler::NewLine();
                $line .= "  Allow from all" . fs_filehandler::NewLine();
                $line .= "</Directory>" . fs_filehandler::NewLine();
                $line .= ctrl_options::GetSystemOption('php_handler') . fs_filehandler::NewLine();
                $line .= ctrl_options::GetSystemOption('dir_index') . fs_filehandler::NewLine();
                $line .= "</virtualhost>" . fs_filehandler::NewLine();
                $line .= "# END DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
                $line .= "################################################################" . fs_filehandler::NewLine();
                $line .= fs_filehandler::NewLine();
                if ($rowvhost['vh_portforward_in'] != 0) {
                    $line .= BuildVhostPortForward($rowvhost['vh_name_vc'], $vhostPort, $useremail);
                }
                $line .= fs_filehandler::NewLine();
                /*
                 * ##################################################
                 * #
                 * # Bandwidth Quotas Check
                 * #
                 * ##################################################
                 */
                //Domain is beyond its quota
            } elseif ($vhostuser['bandwidthquota'] != 0 && $bandwidth > $vhostuser['bandwidthquota']) {
                $line .= "# DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
                $line .= "# THIS DOMAIN HAS BEEN DISABLED FOR BANDWIDTH OVERAGE" . fs_filehandler::NewLine();
                $line .= "<virtualhost " . $vhostIp . ":" . $vhostPort . ">" . fs_filehandler::NewLine();
                $line .= "ServerName " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
                $line .= "ServerAlias " . $rowvhost['vh_name_vc'] . " www." . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
                $line .= "ServerAdmin " . $useremail . fs_filehandler::NewLine();
                $line .= "DocumentRoot \"" . ctrl_options::GetSystemOption('static_dir') . "bandwidthexceeded\"" . fs_filehandler::NewLine();
                $line .= "<Directory />" . fs_filehandler::NewLine();
                $line .= "  Options +FollowSymLinks -Indexes" . fs_filehandler::NewLine();
                $line .= "  AllowOverride All" . fs_filehandler::NewLine();
                $line .= "  Order Allow,Deny" . fs_filehandler::NewLine();
                $line .= "  Allow from all" . fs_filehandler::NewLine();
                $line .= "</Directory>" . fs_filehandler::NewLine();
                $line .= ctrl_options::GetSystemOption('php_handler') . fs_filehandler::NewLine();
                $line .= ctrl_options::GetSystemOption('dir_index') . fs_filehandler::NewLine();
                $line .= "</virtualhost>" . fs_filehandler::NewLine();
                $line .= "# END DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
                $line .= "################################################################" . fs_filehandler::NewLine();
                $line .= fs_filehandler::NewLine();
                if ($rowvhost['vh_portforward_in'] != 0) {
                    $line .= BuildVhostPortForward($rowvhost['vh_name_vc'], $vhostPort, $useremail);
                }
                $line .= fs_filehandler::NewLine();
                /*
                 * ##################################################
                 * #
                 * # Parked Domain
                 * #
                 * ##################################################
                 */
                //Domain is a PARKED domain.
            } elseif ($rowvhost['vh_type_in'] == 3) {
                $line .= "# DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
                $line .= "<virtualhost " . $vhostIp . ":" . $vhostPort . ">" . fs_filehandler::NewLine();
                $line .= "ServerName " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
                $line .= "ServerAlias " . $rowvhost['vh_name_vc'] . " www." . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
                $line .= "ServerAdmin " . $useremail . fs_filehandler::NewLine();
                $line .= "DocumentRoot \"" . ctrl_options::GetSystemOption('parking_path') . "\"" . fs_filehandler::NewLine();
                $line .= "<Directory />" . fs_filehandler::NewLine();
                $line .= "  Options +FollowSymLinks -Indexes" . fs_filehandler::NewLine();
                $line .= "  AllowOverride All" . fs_filehandler::NewLine();
                $line .= "  Order Allow,Deny" . fs_filehandler::NewLine();
                $line .= "  Allow from all" . fs_filehandler::NewLine();
                $line .= "</Directory>" . fs_filehandler::NewLine();
                $line .= ctrl_options::GetSystemOption('php_handler') . fs_filehandler::NewLine();
                $line .= ctrl_options::GetSystemOption('dir_index') . fs_filehandler::NewLine();
                $line .= "# Custom Global Settings (if any exist)" . fs_filehandler::NewLine();
                $line .= ctrl_options::GetSystemOption('global_vhcustom') . fs_filehandler::NewLine();
                $line .= "# Custom VH settings (if any exist)" . fs_filehandler::NewLine();
                $line .= $rowvhost['vh_custom_tx'] . fs_filehandler::NewLine();
                $line .= "</virtualhost>" . fs_filehandler::NewLine();
                $line .= "# END DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
                $line .= "################################################################" . fs_filehandler::NewLine();
                $line .= fs_filehandler::NewLine();
                if ($rowvhost['vh_portforward_in'] != 0) {
                    $line .= BuildVhostPortForward($rowvhost['vh_name_vc'], $vhostPort, $useremail);
                }
                $line .= fs_filehandler::NewLine();
                /*
                 * ##################################################
                 * #
                 * # Regular or Sub domain
                 * #
                 * ##################################################
                 */
                //Domain is a regular domain or a subdomain.
            } else {
                $line .= "# DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
                $line .= "<virtualhost " . $vhostIp . ":" . $vhostPort . ">" . fs_filehandler::NewLine();
                /*
                 * todo
                 */
                // Bandwidth Settings
                //$line .= "Include C:/ZPanel/bin/apache/conf/mod_bw/mod_bw/mod_bw_Administration.conf" . fs_filehandler::NewLine();
                // Server name, alias, email settings
                $line .= "ServerName " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
                $line .= "ServerAlias " . $serveralias . fs_filehandler::NewLine();
                $line .= "ServerAdmin " . $useremail . fs_filehandler::NewLine();
                // Document root
                $line .= "DocumentRoot \"" . ctrl_options::GetSystemOption('hosted_dir') . $vhostuser['username'] . "/public_html" . $rowvhost['vh_directory_vc'] . "\"" . fs_filehandler::NewLine();
                // Get Package openbasedir and suhosin enabled options
                if (ctrl_options::GetSystemOption('use_openbase') == "true") {
                    if ($rowvhost['vh_obasedir_in'] != 0) {
                        $line .= "php_admin_value open_basedir \"" . ctrl_options::GetSystemOption('hosted_dir') . $vhostuser['username'] . "/public_html" . $rowvhost['vh_directory_vc'] . ctrl_options::GetSystemOption('openbase_seperator') . ctrl_options::GetSystemOption('openbase_temp') . "\"" . fs_filehandler::NewLine();
                    }
                }
                if (ctrl_options::GetSystemOption('use_suhosin') == "true") {
                    if ($rowvhost['vh_suhosin_in'] != 0) {
                        $line .= ctrl_options::GetSystemOption('suhosin_value') . fs_filehandler::NewLine();
                    }
                }
                // Logs
                if (!is_dir(ctrl_options::GetSystemOption('log_dir') . "domains/" . $vhostuser['username'] . "/")) {
                    fs_director::CreateDirectory(ctrl_options::GetSystemOption('log_dir') . "domains/" . $vhostuser['username'] . "/");
                }
                $line .= "ErrorLog \"" . ctrl_options::GetSystemOption('log_dir') . "domains/" . $vhostuser['username'] . "/" . $rowvhost['vh_name_vc'] . "-error.log\" " . fs_filehandler::NewLine();
                $line .= "CustomLog \"" . ctrl_options::GetSystemOption('log_dir') . "domains/" . $vhostuser['username'] . "/" . $rowvhost['vh_name_vc'] . "-access.log\" " . ctrl_options::GetSystemOption('access_log_format') . fs_filehandler::NewLine();
                $line .= "CustomLog \"" . ctrl_options::GetSystemOption('log_dir') . "domains/" . $vhostuser['username'] . "/" . $rowvhost['vh_name_vc'] . "-bandwidth.log\" " . ctrl_options::GetSystemOption('bandwidth_log_format') . fs_filehandler::NewLine();
                // Directory options
                $line .= "<Directory />" . fs_filehandler::NewLine();
                $line .= "  Options +FollowSymLinks -Indexes" . fs_filehandler::NewLine();
                $line .= "  AllowOverride All" . fs_filehandler::NewLine();
                $line .= "  Order Allow,Deny" . fs_filehandler::NewLine();
                $line .= "  Allow from all" . fs_filehandler::NewLine();
                $line .= "</Directory>" . fs_filehandler::NewLine();
                // Get Package php and cgi enabled options
                $rows = $zdbh->prepare("SELECT * FROM x_packages WHERE pk_id_pk=:packageid AND pk_deleted_ts IS NULL");
                $rows->bindParam(':packageid', $vhostuser['packageid']);
                $rows->execute();
                $packageinfo = $rows->fetch();
                if ($packageinfo['pk_enablephp_in'] != 0) {
                    $line .= ctrl_options::GetSystemOption('php_handler') . fs_filehandler::NewLine();
                }
                if ($packageinfo['pk_enablecgi_in'] != 0) {
                    $line .= ctrl_options::GetSystemOption('cgi_handler') . fs_filehandler::NewLine();
                    if (!is_dir(ctrl_options::GetSystemOption('hosted_dir') . $vhostuser['username'] . "/public_html" . $rowvhost['vh_directory_vc'] . "/_cgi-bin")) {
                        fs_director::CreateDirectory(ctrl_options::GetSystemOption('hosted_dir') . $vhostuser['username'] . "/public_html" . $rowvhost['vh_directory_vc'] . "/_cgi-bin");
                    }
                }
                // Error documents:- Error pages are added automatically if they are found in the _errorpages directory
                // and if they are a valid error code, and saved in the proper format, i.e. <error_number>.html
                $errorpages = ctrl_options::GetSystemOption('hosted_dir') . $vhostuser['username'] . "/public_html" . $rowvhost['vh_directory_vc'] . "/_errorpages";
                if (is_dir($errorpages)) {
                    if ($handle = opendir($errorpages)) {
                        while (($file = readdir($handle)) !== false) {
                            if ($file != "." && $file != "..") {
                                $page = explode(".", $file);
                                if (!fs_director::CheckForEmptyValue(CheckErrorDocument($page[0]))) {
                                    $line .= "ErrorDocument " . $page[0] . " /_errorpages/" . $page[0] . ".html" . fs_filehandler::NewLine();
                                }
                            }
                        }
                        closedir($handle);
                    }
                }
                // Directory indexes
                $line .= ctrl_options::GetSystemOption('dir_index') . fs_filehandler::NewLine();
                // Global custom global vh entry
                $line .= "# Custom Global Settings (if any exist)" . fs_filehandler::NewLine();
                $line .= ctrl_options::GetSystemOption('global_vhcustom') . fs_filehandler::NewLine();
                // Client custom vh entry
                $line .= "# Custom VH settings (if any exist)" . fs_filehandler::NewLine();
                $line .= $rowvhost['vh_custom_tx'] . fs_filehandler::NewLine();
                // End Virtual Host Settings
                $line .= "</virtualhost>" . fs_filehandler::NewLine();
                $line .= "# END DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
                $line .= "################################################################" . fs_filehandler::NewLine();
                $line .= fs_filehandler::NewLine();
                if ($rowvhost['vh_portforward_in'] != 0) {
                    $line .= BuildVhostPortForward($rowvhost['vh_name_vc'], $vhostPort, $useremail);
                }
                $line .= fs_filehandler::NewLine();
            }
            /*
             * ##################################################
             * #
             * # Disabled domain
             * #
             * ##################################################
             */
        } else {
            //Domain is NOT enabled
            $line .= "# DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
            $line .= "# THIS DOMAIN HAS BEEN DISABLED" . fs_filehandler::NewLine();
            $line .= "<virtualhost " . $vhostIp . ":" . $vhostPort . ">" . fs_filehandler::NewLine();
            $line .= "ServerName " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
            $line .= "ServerAlias " . $rowvhost['vh_name_vc'] . " www." . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
            $line .= "ServerAdmin " . $useremail . fs_filehandler::NewLine();
            $line .= "DocumentRoot \"" . ctrl_options::GetSystemOption('static_dir') . "disabled\"" . fs_filehandler::NewLine();
            $line .= "<Directory />" . fs_filehandler::NewLine();
            $line .= "  Options +FollowSymLinks -Indexes" . fs_filehandler::NewLine();
            $line .= "  AllowOverride All" . fs_filehandler::NewLine();
            $line .= "  Order Allow,Deny" . fs_filehandler::NewLine();
            $line .= "  Allow from all" . fs_filehandler::NewLine();
            $line .= "</Directory>" . fs_filehandler::NewLine();
            $line .= ctrl_options::GetSystemOption('dir_index') . fs_filehandler::NewLine();
            $line .= "</virtualhost>" . fs_filehandler::NewLine();
            $line .= "# END DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
            $line .= "################################################################" . fs_filehandler::NewLine();
        }
    }
    /*
     * ##############################################################################################################
     * #
     * # Write vhost file to disk
     * #
     * ##############################################################################################################
     */
    // write the vhost config file
    $vhconfigfile = ctrl_options::GetSystemOption('apache_vhost');
    if (fs_filehandler::UpdateFile($vhconfigfile, 0777, $line)) {
        // Reset Apache settings to reflect that config file has been written, until the next change.
        $time = time();
        $vsql = $zdbh->prepare("UPDATE x_settings\n                                    SET so_value_tx=:time\n                                    WHERE so_name_vc='apache_changed'");
        $vsql->bindParam(':time', $time);
        $vsql->execute();
        echo "Finished writting Apache Config... Now reloading Apache..." . fs_filehandler::NewLine();
        $returnValue = 0;
        if (sys_versions::ShowOSPlatformVersion() == "Windows") {
            system("" . ctrl_options::GetSystemOption('httpd_exe') . " " . ctrl_options::GetSystemOption('apache_restart') . "", $returnValue);
        } else {
            $command = ctrl_options::GetSystemOption('zsudo');
            $args = array("service", ctrl_options::GetSystemOption('apache_sn'), ctrl_options::GetSystemOption('apache_restart'));
            $returnValue = ctrl_system::systemCommand($command, $args);
        }
        echo "Apache reload " . (0 === $returnValue ? "suceeded" : "failed") . "." . fs_filehandler::NewLine();
    } else {
        return false;
    }
}
예제 #15
0
 static function getResult()
 {
     if (!fs_director::CheckForEmptyValue(self::$error_message)) {
         return ui_sysmessage::shout(ui_language::translate(self::$error_message), 'zannounceerror', 'zannounce');
     }
     if (!fs_director::CheckForEmptyValue(self::$ok)) {
         return ui_sysmessage::shout(ui_language::translate("Changes to your module options have been saved successfully!"));
     } else {
         return ui_language::translate(ui_module::GetModuleDescription());
     }
     return;
 }
예제 #16
0
 static function getResult()
 {
     if (!fs_director::CheckForEmptyValue(self::$alreadyexists)) {
         return ui_sysmessage::shout(ui_language::translate("A mailbox, alias, forwarder or distrubution 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::$noaddress)) {
         return ui_sysmessage::shout(ui_language::translate("Your email address cannot be blank."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$validdomain)) {
         return ui_sysmessage::shout(ui_language::translate("The selected domain was not valid or not yet active."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$ok)) {
         return ui_sysmessage::shout(ui_language::translate("Changes to your aliases have been saved successfully!"), "zannounceok");
     } else {
         return NULL;
     }
     return;
 }
 static function getResult()
 {
     if (!fs_director::CheckForEmptyValue(self::$blank)) {
         return ui_sysmessage::shout(ui_language::translate("You need to specify a user name and select a database to create your MySQL user."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$rootabuse)) {
         return ui_sysmessage::shout(ui_language::translate("You cannot create a user named 'root'! This attempt has been logged and the system administrator notified!."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$alreadyexists)) {
         return ui_sysmessage::shout(ui_language::translate("A MySQL username with that name already appears to exsist."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$badname)) {
         return ui_sysmessage::shout(ui_language::translate("Your MySQL user name is not valid. Please enter a valid MySQL user name."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$badpass)) {
         return ui_sysmessage::shout(ui_language::translate("Your MySQL password is not valid. Valid characters are A-Z, a-z, 0-9."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$badIP)) {
         return ui_sysmessage::shout(ui_language::translate("The IP address is not valid. Please enter a valid IP address."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$dbalreadyadded)) {
         return ui_sysmessage::shout(ui_language::translate("That database has already been added to this user."), "zannounceerror");
     }
     if (!fs_director::CheckForEmptyValue(self::$ok)) {
         return ui_sysmessage::shout(ui_language::translate("Changes to your MySQL users have been saved successfully!"), "zannounceok");
     }
     return;
 }
 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;
 }
 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;
 }
예제 #20
0
 static function getResult()
 {
     if (!fs_director::CheckForEmptyValue(self::$error)) {
         if (self::$error == "ok") {
             return ui_sysmessage::shout(ui_language::translate("Your account password been changed successfully!"), "zannounceok");
         }
         if (self::$error == "nomatch") {
             return ui_sysmessage::shout(ui_language::translate("Sorry, your current password does not match the one on your account!"), "zannounceerror");
         }
         if (self::$error == "error") {
             return ui_sysmessage::shout(ui_language::translate("An error occured and your MADmin account password could not be updated. Please ensure you entered all passwords correctly and try again."), "zannounceerror");
         }
     } else {
         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");
         }
         return;
     }
 }
예제 #21
0
<?php

echo fs_filehandler::NewLine() . "START DNS Manager Hook" . fs_filehandler::NewLine();
if (ui_module::CheckModuleEnabled('DNS Config')) {
    echo "DNS Manager module ENABLED..." . fs_filehandler::NewLine();
    if (!fs_director::CheckForEmptyValue(ctrl_options::GetSystemOption('dns_hasupdates'))) {
        echo "DNS Records have changed... Writing new/updated records..." . fs_filehandler::NewLine();
        WriteDNSZoneRecordsHook();
        WriteDNSNamedHook();
        ResetDNSRecordsUpatedHook();
        PurgeOldZoneDNSRecordsHook();
        ReloadBindHook();
    } else {
        echo "DNS Records have not changed...nothing to do." . fs_filehandler::NewLine();
    }
} else {
    echo "DNS Manager module DISABLED...nothing to do." . fs_filehandler::NewLine();
}
echo "END DNS Manager Hook." . fs_filehandler::NewLine();
function WriteDNSZoneRecordsHook()
{
    global $zdbh;
    //Get list of domains id that have rows in the DNS table
    $DomainsNeedingUpdate = explode(",", ctrl_options::GetSystemOption('dns_hasupdates'));
    //Get list of domains id that have rows in the dns table
    $DomainsInDnsTable = array();
    $sql = $zdbh->prepare("SELECT dn_vhost_fk FROM x_dns WHERE dn_deleted_ts IS NULL GROUP BY dn_vhost_fk");
    $sql->execute();
    while ($rowdns = $sql->fetch()) {
        $DomainsInDnsTable[] = $rowdns['dn_vhost_fk'];
    }
예제 #22
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;
 }
예제 #23
0
파일: postfix.php 프로젝트: BIGGANI/zpanelx
    $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();
    }
}
예제 #24
0
    $ftp_db = new db_driver("mysql:host=" . $host . ";dbname={$ftp_db}", $z_db_user, $z_db_pass);
} catch (PDOException $e) {
}
// Included after acount has been created
if (!fs_director::CheckForEmptyValue(self::$create)) {
    $homedir = ctrl_options::GetSystemOption('hosted_dir') . $currentuser['username'] . $homedirectory_to_use . "";
    $sql = $ftp_db->prepare("INSERT INTO ftpquotalimits (name, quota_type, per_session, limit_type, bytes_in_avail, bytes_out_avail, bytes_xfer_avail, files_in_avail, files_out_avail, files_xfer_avail) VALUES (:username, 'user', 'true', 'hard', 0, 0, 0, 0, 0, 0);");
    $sql->bindParam(':username', $username);
    $sql->execute();
    $sql = $ftp_db->prepare("INSERT INTO ftpuser (id, userid, passwd, homedir, shell, count, accessed, modified) VALUES ('', :username, :password, :homedir, '/sbin/nologin', 0, '', '');");
    $sql->bindParam(':username', $username);
    $sql->bindParam(':password', $password);
    $sql->bindParam(':homedir', $homedir);
    $sql->execute();
}
// Included after account is created
if (!fs_director::CheckForEmptyValue(self::$delete)) {
    $sql = $ftp_db->prepare("DELETE FROM ftpuser  WHERE userid=:userid");
    $sql->bindParam(':userid', $rowftp['ft_user_vc']);
    $sql->execute();
    $sql = $ftp_db->prepare("DELETE FROM ftpquotalimits WHERE name=:username");
    $sql->bindParam(':username', $rowftp['ft_user_vc']);
    $sql->execute();
}
// Included after account password has been reset
if (!fs_director::CheckForEmptyValue(self::$reset)) {
    $sql = $ftp_db->prepare("UPDATE ftpuser SET passwd=:password WHERE userid=:username");
    $sql->bindParam(':username', $rowftp['ft_user_vc']);
    $sql->bindParam(':password', $password);
    $sql->execute();
}
예제 #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
        $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();
}
 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
 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;
 }
예제 #29
0
function WriteVhostConfigFile()
{
    global $zdbh;
    //Get email for server admin of MADmin
    $getserveremail = $zdbh->query("SELECT ac_email_vc FROM x_accounts where ac_id_pk=1")->fetch();
    $serveremail = $getserveremail['ac_email_vc'] != "" ? $getserveremail['ac_email_vc'] : "postmaster@" . ctrl_options::GetSystemOption('MADmin_domain');
    $VHostDefaultPort = ctrl_options::GetSystemOption('apache_port');
    $customPorts = array(ctrl_options::GetSystemOption('MADmin_port'));
    $portQuery = $zdbh->prepare("SELECT vh_custom_port_in FROM x_vhosts WHERE vh_deleted_ts IS NULL");
    $portQuery->execute();
    while ($rowport = $portQuery->fetch()) {
        $customPorts[] = empty($rowport['vh_custom_port_in']) ? $VHostDefaultPort : $rowport['vh_custom_port_in'];
    }
    $customPortList = array_unique($customPorts);
    /*
     * ###########################################################################​###################################
     * #
     * # Default Virtual Host Container
     * #
     * ###########################################################################​###################################
     */
    $line = "################################################################" . fs_filehandler::NewLine();
    $line .= "# Apache VHOST configuration file" . fs_filehandler::NewLine();
    $line .= "# Automatically generated by MADmin " . sys_versions::ShowMADminVersion() . fs_filehandler::NewLine();
    $line .= "# Generated on: " . date(ctrl_options::GetSystemOption('MADmin_df'), time()) . fs_filehandler::NewLine();
    $line .= "#==== YOU MUST NOT EDIT THIS FILE : IT WILL BE OVERWRITTEN ====" . fs_filehandler::NewLine();
    $line .= "# Use MADmin Menu -> Admin -> Module Admin -> Apache config" . fs_filehandler::NewLine();
    $line .= "################################################################" . fs_filehandler::NewLine();
    $line .= fs_filehandler::NewLine();
    # NameVirtualHost is still needed for Apache 2.2 but must be removed for apache 2.3
    if ((double) sys_versions::ShowApacheVersion() < 2.3) {
        foreach ($customPortList as $port) {
            $line .= "NameVirtualHost *:" . $port . fs_filehandler::NewLine();
        }
    }
    # Listen is mandatory for each port <> 80 (80 is defined in system config)
    foreach ($customPortList as $port) {
        $line .= "Listen " . $port . fs_filehandler::NewLine();
    }
    $line .= fs_filehandler::NewLine();
    $line .= "# Configuration for MADmin control panel." . fs_filehandler::NewLine();
    $line .= "<VirtualHost *:" . ctrl_options::GetSystemOption('MADmin_port') . ">" . fs_filehandler::NewLine();
    $line .= "ServerAdmin " . $serveremail . fs_filehandler::NewLine();
    $line .= 'DocumentRoot "' . ctrl_options::GetSystemOption('MADmin_root') . '"' . fs_filehandler::NewLine();
    $line .= "ServerName " . ctrl_options::GetSystemOption('MADmin_domain') . fs_filehandler::NewLine();
    $line .= 'ErrorLog "' . ctrl_options::GetSystemOption('log_dir') . 'MADmin-error.log" ' . fs_filehandler::NewLine();
    $line .= 'CustomLog "' . ctrl_options::GetSystemOption('log_dir') . 'MADmin-access.log" ' . ctrl_options::GetSystemOption('access_log_format') . fs_filehandler::NewLine();
    $line .= 'CustomLog "' . ctrl_options::GetSystemOption('log_dir') . 'MADmin-bandwidth.log" ' . ctrl_options::GetSystemOption('bandwidth_log_format') . fs_filehandler::NewLine();
    $line .= "AddType application/x-httpd-php .php" . fs_filehandler::NewLine();
    $line .= '<Directory "' . ctrl_options::GetSystemOption('MADmin_root') . '">' . fs_filehandler::NewLine();
    $line .= "Options +FollowSymLinks -Indexes" . fs_filehandler::NewLine();
    $line .= "    AllowOverride All" . fs_filehandler::NewLine();
    if ((double) sys_versions::ShowApacheVersion() < 2.4) {
        $line .= "    Order allow,deny" . fs_filehandler::NewLine();
        $line .= "    Allow from all" . fs_filehandler::NewLine();
    } else {
        $line .= "    Require all granted" . fs_filehandler::NewLine();
    }
    $line .= "</Directory>" . fs_filehandler::NewLine();
    $line .= fs_filehandler::NewLine();
    $line .= "# Custom settings are loaded below this line (if any exist)" . fs_filehandler::NewLine();
    // Global custom MADmin entry
    $line .= ctrl_options::GetSystemOption('global_zpcustom') . fs_filehandler::NewLine();
    $line .= "</VirtualHost>" . fs_filehandler::NewLine();
    $line .= fs_filehandler::NewLine();
    $line .= "################################################################" . fs_filehandler::NewLine();
    $line .= "# MADmin generated VHOST configurations below....." . fs_filehandler::NewLine();
    $line .= "################################################################" . fs_filehandler::NewLine();
    $line .= fs_filehandler::NewLine();
    /*
     * ##############################################################################################################
     * #
     * # All Virtual Host Containers
     * #
     * ##############################################################################################################
     */
    // MADmin virtual host container configuration
    $sql = $zdbh->prepare("SELECT * FROM x_vhosts WHERE vh_deleted_ts IS NULL");
    $sql->execute();
    while ($rowvhost = $sql->fetch()) {
        // Grab some variables we will use for later...
        $vhostuser = ctrl_users::GetUserDetail($rowvhost['vh_acc_fk']);
        $bandwidth = ctrl_users::GetQuotaUsages('bandwidth', $vhostuser['userid']);
        $diskspace = ctrl_users::GetQuotaUsages('diskspace', $vhostuser['userid']);
        // Set the vhosts to "LIVE"
        $vsql = $zdbh->prepare("UPDATE x_vhosts SET vh_active_in=1 WHERE vh_id_pk=:id");
        $vsql->bindParam(':id', $rowvhost['vh_id_pk']);
        $vsql->execute();
        // Add a default email if no email found for client.
        $useremail = fs_director::CheckForEmptyValue($vhostuser['email']) ? "postmaster@" . $rowvhost['vh_name_vc'] : $vhostuser['email'];
        // Check if domain or subdomain to see if we add an alias with 'www'
        $serveralias = $rowvhost['vh_type_in'] == 2 ? '' : " www." . $rowvhost['vh_name_vc'];
        $vhostPort = fs_director::CheckForEmptyValue($rowvhost['vh_custom_port_in']) ? $VHostDefaultPort : $rowvhost['vh_custom_port_in'];
        $vhostIp = fs_director::CheckForEmptyValue($rowvhost['vh_custom_ip_vc']) ? "*" : $rowvhost['vh_custom_ip_vc'];
        //Domain is enabled
        //Line1: Domain enabled & Client also is enabled.
        //Line2: Domain enabled & Client may be disabled, but 'Allow Disabled' = 'true' in apache settings.
        if ($rowvhost['vh_enabled_in'] == 1 && ctrl_users::CheckUserEnabled($rowvhost['vh_acc_fk']) || $rowvhost['vh_enabled_in'] == 1 && ctrl_options::GetSystemOption('apache_allow_disabled') == strtolower("true")) {
            /*
             * ##################################################
             * #
             * # Disk Quotas Check
             * #
             * ##################################################
             */
            //Domain is beyond its diskusage
            if ($vhostuser['diskquota'] != 0 && $diskspace > $vhostuser['diskquota']) {
                $line .= "# DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
                $line .= "# THIS DOMAIN HAS BEEN DISABLED FOR QUOTA OVERAGE" . fs_filehandler::NewLine();
                $line .= "<virtualhost " . $vhostIp . ":" . $vhostPort . ">" . fs_filehandler::NewLine();
                $line .= "ServerName " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
                $line .= "ServerAlias www." . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
                $line .= "ServerAdmin " . $useremail . fs_filehandler::NewLine();
                $line .= 'DocumentRoot "' . ctrl_options::GetSystemOption('static_dir') . 'diskexceeded"' . fs_filehandler::NewLine();
                $line .= '<Directory "' . ctrl_options::GetSystemOption('static_dir') . 'diskexceeded">' . fs_filehandler::NewLine();
                $line .= "  Options +FollowSymLinks -Indexes" . fs_filehandler::NewLine();
                $line .= "  AllowOverride All" . fs_filehandler::NewLine();
                $line .= "  Order Allow,Deny" . fs_filehandler::NewLine();
                $line .= "  Allow from all" . fs_filehandler::NewLine();
                $line .= "</Directory>" . fs_filehandler::NewLine();
                $line .= ctrl_options::GetSystemOption('php_handler') . fs_filehandler::NewLine();
                $line .= ctrl_options::GetSystemOption('dir_index') . fs_filehandler::NewLine();
                $line .= "</virtualhost>" . fs_filehandler::NewLine();
                $line .= "# END DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
                $line .= "################################################################" . fs_filehandler::NewLine();
                $line .= fs_filehandler::NewLine();
                if ($rowvhost['vh_portforward_in'] != 0) {
                    $line .= BuildVhostPortForward($rowvhost['vh_name_vc'], $vhostPort, $useremail);
                }
                $line .= fs_filehandler::NewLine();
                /*
                 * ##################################################
                 * #
                 * # Bandwidth Quotas Check
                 * #
                 * ##################################################
                 */
                //Domain is beyond its quota
            } elseif ($vhostuser['bandwidthquota'] != 0 && $bandwidth > $vhostuser['bandwidthquota']) {
                $line .= "# DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
                $line .= "# THIS DOMAIN HAS BEEN DISABLED FOR BANDWIDTH OVERAGE" . fs_filehandler::NewLine();
                $line .= "<virtualhost " . $vhostIp . ":" . $vhostPort . ">" . fs_filehandler::NewLine();
                $line .= "ServerName " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
                $line .= "ServerAlias www." . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
                $line .= "ServerAdmin " . $useremail . fs_filehandler::NewLine();
                $line .= 'DocumentRoot "' . ctrl_options::GetSystemOption('static_dir') . 'bandwidthexceeded"' . fs_filehandler::NewLine();
                $line .= '<Directory "' . ctrl_options::GetSystemOption('static_dir') . 'bandwidthexceeded">' . fs_filehandler::NewLine();
                $line .= "  Options +FollowSymLinks -Indexes" . fs_filehandler::NewLine();
                $line .= "  AllowOverride All" . fs_filehandler::NewLine();
                $line .= "  Order Allow,Deny" . fs_filehandler::NewLine();
                $line .= "  Allow from all" . fs_filehandler::NewLine();
                $line .= "</Directory>" . fs_filehandler::NewLine();
                $line .= ctrl_options::GetSystemOption('php_handler') . fs_filehandler::NewLine();
                $line .= ctrl_options::GetSystemOption('dir_index') . fs_filehandler::NewLine();
                $line .= "</virtualhost>" . fs_filehandler::NewLine();
                $line .= "# END DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
                $line .= "################################################################" . fs_filehandler::NewLine();
                $line .= fs_filehandler::NewLine();
                if ($rowvhost['vh_portforward_in'] != 0) {
                    $line .= BuildVhostPortForward($rowvhost['vh_name_vc'], $vhostPort, $useremail);
                }
                $line .= fs_filehandler::NewLine();
                /*
                 * ##################################################
                 * #
                 * # Parked Domain
                 * #
                 * ##################################################
                 */
                //Domain is a PARKED domain.
            } elseif ($rowvhost['vh_type_in'] == 3) {
                $line .= "# DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
                $line .= "<virtualhost " . $vhostIp . ":" . $vhostPort . ">" . fs_filehandler::NewLine();
                $line .= "ServerName " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
                $line .= "ServerAlias www." . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
                $line .= "ServerAdmin " . $useremail . fs_filehandler::NewLine();
                $line .= 'DocumentRoot "' . ctrl_options::GetSystemOption('parking_path') . '"' . fs_filehandler::NewLine();
                $line .= '<Directory "' . ctrl_options::GetSystemOption('parking_path') . '">' . fs_filehandler::NewLine();
                $line .= "  Options +FollowSymLinks -Indexes" . fs_filehandler::NewLine();
                $line .= "  AllowOverride All" . fs_filehandler::NewLine();
                $line .= "  Order Allow,Deny" . fs_filehandler::NewLine();
                $line .= "  Allow from all" . fs_filehandler::NewLine();
                $line .= "</Directory>" . fs_filehandler::NewLine();
                $line .= ctrl_options::GetSystemOption('php_handler') . fs_filehandler::NewLine();
                $line .= ctrl_options::GetSystemOption('dir_index') . fs_filehandler::NewLine();
                $line .= "# Custom Global Settings (if any exist)" . fs_filehandler::NewLine();
                $line .= ctrl_options::GetSystemOption('global_vhcustom') . fs_filehandler::NewLine();
                $line .= "# Custom VH settings (if any exist)" . fs_filehandler::NewLine();
                $line .= $rowvhost['vh_custom_tx'] . fs_filehandler::NewLine();
                $line .= "</virtualhost>" . fs_filehandler::NewLine();
                $line .= "# END DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
                $line .= "################################################################" . fs_filehandler::NewLine();
                $line .= fs_filehandler::NewLine();
                if ($rowvhost['vh_portforward_in'] != 0) {
                    $line .= BuildVhostPortForward($rowvhost['vh_name_vc'], $vhostPort, $useremail);
                }
                $line .= fs_filehandler::NewLine();
                /*
                 * ##################################################
                 * #
                 * # Regular or Sub domain
                 * #
                 * ##################################################
                 */
                //Domain is a regular domain or a subdomain.
            } else {
                $RootDir = '"' . ctrl_options::GetSystemOption('hosted_dir') . $vhostuser['username'] . '/public_html' . $rowvhost['vh_directory_vc'] . '"';
                $line .= "# DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
                $line .= "<virtualhost " . $vhostIp . ":" . $vhostPort . ">" . fs_filehandler::NewLine();
                /*
                 * todo
                 */
                // Bandwidth Settings
                //$line .= "Include C:/MADmin/bin/apache/conf/mod_bw/mod_bw/mod_bw_Administration.conf" . fs_filehandler::NewLine();
                // Server name, alias, email settings
                $line .= "ServerName " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
                if (!empty($serveralias)) {
                    $line .= "ServerAlias " . $serveralias . fs_filehandler::NewLine();
                }
                $line .= "ServerAdmin " . $useremail . fs_filehandler::NewLine();
                // Document root
                $line .= 'DocumentRoot ' . $RootDir . fs_filehandler::NewLine();
                // Get Package openbasedir and suhosin enabled options
                if (ctrl_options::GetSystemOption('use_openbase') == "true") {
                    if ($rowvhost['vh_obasedir_in'] != 0) {
                        $line .= 'php_admin_value open_basedir "' . ctrl_options::GetSystemOption('hosted_dir') . $vhostuser['username'] . "/public_html" . $rowvhost['vh_directory_vc'] . ctrl_options::GetSystemOption('openbase_seperator') . ctrl_options::GetSystemOption('openbase_temp') . '"' . fs_filehandler::NewLine();
                    }
                }
                if (ctrl_options::GetSystemOption('use_suhosin') == "true") {
                    if ($rowvhost['vh_suhosin_in'] != 0) {
                        $line .= ctrl_options::GetSystemOption('suhosin_value') . fs_filehandler::NewLine();
                    }
                }
                // Logs
                if (!is_dir(ctrl_options::GetSystemOption('log_dir') . "domains/" . $vhostuser['username'] . "/")) {
                    fs_director::CreateDirectory(ctrl_options::GetSystemOption('log_dir') . "domains/" . $vhostuser['username'] . "/");
                }
                $line .= 'ErrorLog "' . ctrl_options::GetSystemOption('log_dir') . "domains/" . $vhostuser['username'] . "/" . $rowvhost['vh_name_vc'] . '-error.log" ' . fs_filehandler::NewLine();
                $line .= 'CustomLog "' . ctrl_options::GetSystemOption('log_dir') . "domains/" . $vhostuser['username'] . "/" . $rowvhost['vh_name_vc'] . '-access.log" ' . ctrl_options::GetSystemOption('access_log_format') . fs_filehandler::NewLine();
                $line .= 'CustomLog "' . ctrl_options::GetSystemOption('log_dir') . "domains/" . $vhostuser['username'] . "/" . $rowvhost['vh_name_vc'] . '-bandwidth.log" ' . ctrl_options::GetSystemOption('bandwidth_log_format') . fs_filehandler::NewLine();
                // Directory options
                $line .= '<Directory ' . $RootDir . '>' . fs_filehandler::NewLine();
                $line .= "  Options +FollowSymLinks -Indexes" . fs_filehandler::NewLine();
                $line .= "  AllowOverride All" . fs_filehandler::NewLine();
                $line .= "  Order Allow,Deny" . fs_filehandler::NewLine();
                $line .= "  Allow from all" . fs_filehandler::NewLine();
                $line .= "</Directory>" . fs_filehandler::NewLine();
                // Enable Gzip until we set this as an option , we might commenbt this too and allow manual switch
                $line .= "AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript" . fs_filehandler::NewLine();
                // Get Package php and cgi enabled options
                $rows = $zdbh->prepare("SELECT * FROM x_packages WHERE pk_id_pk=:packageid AND pk_deleted_ts IS NULL");
                $rows->bindParam(':packageid', $vhostuser['packageid']);
                $rows->execute();
                $packageinfo = $rows->fetch();
                if ($packageinfo['pk_enablephp_in'] != 0) {
                    $line .= ctrl_options::GetSystemOption('php_handler') . fs_filehandler::NewLine();
                }
                # curently disabled because un secure
                # need correct cleaning in interface for full removal or in comment here until restoration
                #                if ( $packageinfo[ 'pk_enablecgi_in' ] <> 0 ) {
                #                     $line .= ctrl_options::GetSystemOption( 'cgi_handler' ) . fs_filehandler::NewLine();
                #                     if ( !is_dir( ctrl_options::GetSystemOption( 'hosted_dir' ) . $vhostuser[ 'username' ] . "/public_html" . $rowvhost[ 'vh_directory_vc' ] . "/_cgi-bin" ) ) {
                #                         fs_director::CreateDirectory( ctrl_options::GetSystemOption( 'hosted_dir' ) . $vhostuser[ 'username' ] . "/public_html" . $rowvhost[ 'vh_directory_vc' ] . "/_cgi-bin" );
                #                     }
                #                 }
                // Error documents:- Error pages are added automatically if they are found in the _errorpages directory
                // and if they are a valid error code, and saved in the proper format, i.e. <error_number>.html
                $errorpages = ctrl_options::GetSystemOption('hosted_dir') . $vhostuser['username'] . "/public_html" . $rowvhost['vh_directory_vc'] . "/_errorpages";
                if (is_dir($errorpages)) {
                    if ($handle = opendir($errorpages)) {
                        while (($file = readdir($handle)) !== false) {
                            if ($file != "." && $file != "..") {
                                $page = explode(".", $file);
                                if (!fs_director::CheckForEmptyValue(CheckErrorDocument($page[0]))) {
                                    $line .= "ErrorDocument " . $page[0] . " /_errorpages/" . $page[0] . ".html" . fs_filehandler::NewLine();
                                }
                            }
                        }
                        closedir($handle);
                    }
                }
                // Directory indexes
                $line .= ctrl_options::GetSystemOption('dir_index') . fs_filehandler::NewLine();
                // Global custom global vh entry
                $line .= "# Custom Global Settings (if any exist)" . fs_filehandler::NewLine();
                $line .= ctrl_options::GetSystemOption('global_vhcustom') . fs_filehandler::NewLine();
                // Client custom vh entry
                $line .= "# Custom VH settings (if any exist)" . fs_filehandler::NewLine();
                $line .= $rowvhost['vh_custom_tx'] . fs_filehandler::NewLine();
                // End Virtual Host Settings
                $line .= "</virtualhost>" . fs_filehandler::NewLine();
                $line .= "# END DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
                $line .= "################################################################" . fs_filehandler::NewLine();
                $line .= fs_filehandler::NewLine();
                if ($rowvhost['vh_portforward_in'] != 0) {
                    $line .= BuildVhostPortForward($rowvhost['vh_name_vc'], $vhostPort, $useremail);
                }
                $line .= fs_filehandler::NewLine();
            }
            /*
             * ##################################################
             * #
             * # Disabled domain
             * #
             * ##################################################
             */
        } else {
            //Domain is NOT enabled
            $line .= "# DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
            $line .= "# THIS DOMAIN HAS BEEN DISABLED" . fs_filehandler::NewLine();
            $line .= "<virtualhost " . $vhostIp . ":" . $vhostPort . ">" . fs_filehandler::NewLine();
            $line .= "ServerName " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
            $line .= "ServerAlias www." . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
            $line .= "ServerAdmin " . $useremail . fs_filehandler::NewLine();
            $line .= 'DocumentRoot "' . ctrl_options::GetSystemOption('static_dir') . 'disabled"' . fs_filehandler::NewLine();
            $line .= '<Directory "' . ctrl_options::GetSystemOption('static_dir') . 'disabled">' . fs_filehandler::NewLine();
            $line .= "  Options +FollowSymLinks -Indexes" . fs_filehandler::NewLine();
            $line .= "  AllowOverride All" . fs_filehandler::NewLine();
            $line .= "  Order Allow,Deny" . fs_filehandler::NewLine();
            $line .= "  Allow from all" . fs_filehandler::NewLine();
            $line .= "</Directory>" . fs_filehandler::NewLine();
            $line .= ctrl_options::GetSystemOption('dir_index') . fs_filehandler::NewLine();
            $line .= "</virtualhost>" . fs_filehandler::NewLine();
            $line .= "# END DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
            $line .= "################################################################" . fs_filehandler::NewLine();
        }
    }
    /*
     * ##############################################################################################################
     * #
     * # Write vhost file to disk
     * #
     * ##############################################################################################################
     */
    // write the vhost config file
    $vhconfigfile = ctrl_options::GetSystemOption('apache_vhost');
    if (fs_filehandler::UpdateFile($vhconfigfile, 0777, $line)) {
        // Reset Apache settings to reflect that config file has been written, until the next change.
        $time = time();
        $vsql = $zdbh->prepare("UPDATE x_settings\n                                    SET so_value_tx=:time\n                                    WHERE so_name_vc='apache_changed'");
        $vsql->bindParam(':time', $time);
        $vsql->execute();
        echo "Finished writting Apache Config... Now reloading Apache..." . fs_filehandler::NewLine();
        $returnValue = 0;
        if (sys_versions::ShowOSPlatformVersion() == "Windows") {
            system("" . ctrl_options::GetSystemOption('httpd_exe') . " " . ctrl_options::GetSystemOption('apache_restart') . "", $returnValue);
        } else {
            $command = ctrl_options::GetSystemOption('zsudo');
            $args = array("service", ctrl_options::GetSystemOption('apache_sn'), ctrl_options::GetSystemOption('apache_restart'));
            $returnValue = ctrl_system::systemCommand($command, $args);
        }
        echo "Apache reload " . (0 === $returnValue ? "suceeded" : "failed") . "." . fs_filehandler::NewLine();
    } else {
        return false;
    }
}
예제 #30
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;
 }