function GenerateWebalizerStats()
{
    global $zdbh;
    $sql = $zdbh->prepare("SELECT * FROM x_vhosts LEFT JOIN x_accounts ON x_vhosts.vh_acc_fk=x_accounts.ac_id_pk WHERE vh_deleted_ts IS NULL");
    $sql->execute();
    echo "Generating webalizer stats html..." . fs_filehandler::NewLine();
    while ($rowvhost = $sql->fetch()) {
        $basedir = ctrl_options::GetSystemOption('MADmin_root') . "modules/webalizer_stats/stats/" . $rowvhost['ac_user_vc'] . "/" . $rowvhost['vh_name_vc'];
        if (!file_exists($basedir)) {
            @mkdir($basedir, 0755, TRUE);
        }
        /** set webalizer command dependant on OS */
        if (sys_versions::ShowOSPlatformVersion() == "Windows") {
            $command = ctrl_options::GetSystemOption('MADmin_root') . 'modules/webalizer_stats/bin/webalizer.exe';
        } else {
            chmod(ctrl_options::GetSystemOption('MADmin_root') . "modules/webalizer_stats/bin/webalizer", 4777);
            $command = "webalizer";
        }
        /** all other args and flags are the same so keep them outsite to avoid duplication */
        $flag = '-o';
        $secondFlags = '-d -F clf -n';
        $domain = $rowvhost['vh_name_vc'];
        $logFile = realpath(ctrl_options::GetSystemOption('log_dir') . 'domains/' . $rowvhost['ac_user_vc'] . '/' . $rowvhost['vh_name_vc'] . '-access.log');
        $statsPath = ctrl_options::GetSystemOption('MADmin_root') . "modules/webalizer_stats/stats/" . $rowvhost['ac_user_vc'] . '/' . $rowvhost['vh_name_vc'];
        /** build arg array, this is in the required order! do not just change the order of this array */
        $args = array($logFile, $flag, $statsPath, $secondFlags, $domain);
        echo "Generating stats for: " . $rowvhost['ac_user_vc'] . "/" . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
        $returnValue = ctrl_system::systemCommand($command, $args);
        echo (0 === $returnValue ? 'Succeeded' : 'Failed') . fs_filehandler::NewLine();
    }
}
function GenerateVisitorStats()
{
    include 'cnf/db.php';
    $z_db_user = $user;
    $z_db_pass = $pass;
    try {
        $zdbh = new db_driver("mysql:host=localhost;dbname=" . $dbname . "", $z_db_user, $z_db_pass);
    } catch (PDOException $e) {
    }
    $sql = $zdbh->prepare("SELECT * FROM x_vhosts LEFT JOIN x_accounts ON x_vhosts.vh_acc_fk=x_accounts.ac_id_pk WHERE vh_deleted_ts IS NULL");
    $sql->execute();
    echo "Generating visitor stats html..." . fs_filehandler::NewLine();
    while ($rowvhost = $sql->fetch()) {
        if (!file_exists(ctrl_options::GetOption('sentora_root') . "modules/visitor_stats/stats/" . $rowvhost['ac_user_vc'] . "")) {
            @mkdir(ctrl_options::GetOption('sentora_root') . "modules/visitor_stats/stats/" . $rowvhost['ac_user_vc'] . "", 777, TRUE);
        }
        if (sys_versions::ShowOSPlatformVersion() == "Windows") {
            $runcommand = ctrl_options::GetOption('sentora_root') . "modules/visitor_stats/bin/visitors.exe -A -m 30 " . ctrl_options::GetOption('log_dir') . "domains/" . $rowvhost['ac_user_vc'] . "/" . $rowvhost['vh_name_vc'] . "-access.log -o html > " . ctrl_options::GetOption('sentora_root') . "modules/visitor_stats/stats/" . $rowvhost['ac_user_vc'] . "/" . $rowvhost['vh_name_vc'] . ".html";
        } else {
            chmod(ctrl_options::GetOption('sentora_root') . "modules/visitor_stats/bin/visitors", 4777);
            $runcommand = ctrl_options::GetOption('sentora_root') . "modules/visitor_stats/bin/visitors -A -m 30 " . ctrl_options::GetOption('log_dir') . "domains/" . $rowvhost['ac_user_vc'] . "/" . $rowvhost['vh_name_vc'] . "-access.log -o html > " . ctrl_options::GetOption('sentora_root') . "modules/visitor_stats/stats/" . $rowvhost['ac_user_vc'] . "/" . $rowvhost['vh_name_vc'] . ".html";
        }
        echo "Generating stats for: " . $rowvhost['ac_user_vc'] . "/" . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
        system($runcommand);
    }
}
Exemple #3
0
 /**
  * Converts to proper slashes based on OS platform.
  * @author Bobby Allen (ballen@bobbyallen.me)
  * @param string $string The string to that of which to convert the slashes in.
  * @return string
  */
 static function ConvertSlashes($string)
 {
     if (sys_versions::ShowOSPlatformVersion() != "Windows") {
         $retval = self::SlashesToNIX($string);
     } else {
         $retval = self::SlashesToWin($string);
     }
     return $retval;
 }
function WriteCronFile()
{
    global $zdbh;
    $line = "";
    $sql = "SELECT * FROM x_cronjobs WHERE ct_deleted_ts IS NULL";
    $numrows = $zdbh->query($sql);
    if ($numrows->fetchColumn() != 0) {
        $sql = $zdbh->prepare($sql);
        $sql->execute();
        $line .= "#################################################################################" . fs_filehandler::NewLine();
        $line .= "# CRONTAB FOR ZPANEL CRON MANAGER MODULE                                         " . fs_filehandler::NewLine();
        $line .= "# Module Developed by Bobby Allen, 17/12/2009                                    " . fs_filehandler::NewLine();
        $line .= "# Automatically generated by Sentora " . sys_versions::ShowSentoraVersion() . "      " . fs_filehandler::NewLine();
        $line .= "#################################################################################" . fs_filehandler::NewLine();
        $line .= "# WE DO NOT RECOMMEND YOU MODIFY THIS FILE DIRECTLY, PLEASE USE ZPANEL INSTEAD!  " . fs_filehandler::NewLine();
        $line .= "#################################################################################" . fs_filehandler::NewLine();
        if (sys_versions::ShowOSPlatformVersion() == "Windows") {
            $line .= "# Cron Debug infomation can be found in this file here:-                        " . fs_filehandler::NewLine();
            $line .= "# C:\\WINDOWS\\System32\\crontab.txt                                                " . fs_filehandler::NewLine();
            $line .= "#################################################################################" . fs_filehandler::NewLine();
            $line .= "" . ctrl_options::GetSystemOption('daemon_timing') . " " . ctrl_options::GetSystemOption('php_exer') . " " . ctrl_options::GetSystemOption('daemon_exer') . "" . fs_filehandler::NewLine();
            $line .= "#################################################################################" . fs_filehandler::NewLine();
        }
        $line .= "# DO NOT MANUALLY REMOVE ANY OF THE CRON ENTRIES FROM THIS FILE, USE ZPANEL      " . fs_filehandler::NewLine();
        $line .= "# INSTEAD! THE ABOVE ENTRIES ARE USED FOR ZPANEL TASKS, DO NOT REMOVE THEM!      " . fs_filehandler::NewLine();
        $line .= "#################################################################################" . fs_filehandler::NewLine();
        while ($rowcron = $sql->fetch()) {
            //$rowclient = $zdbh->query("SELECT * FROM x_accounts WHERE ac_id_pk=" . $rowcron['ct_acc_fk'] . " AND ac_deleted_ts IS NULL")->fetch();
            $numrows = $zdbh->prepare("SELECT * FROM x_accounts WHERE ac_id_pk=:userid AND ac_deleted_ts IS NULL");
            $numrows->bindParam(':userid', $rowcron['ct_acc_fk']);
            $numrows->execute();
            $rowclient = $numrows->fetch();
            if ($rowclient && $rowclient['ac_enabled_in'] != 0) {
                $line .= "# CRON ID: " . $rowcron['ct_id_pk'] . "" . fs_filehandler::NewLine();
                $line .= "" . $rowcron['ct_timing_vc'] . " " . ctrl_options::GetSystemOption('php_exer') . " " . $rowcron['ct_fullpath_vc'] . "" . fs_filehandler::NewLine();
                $line .= "# END CRON ID: " . $rowcron['ct_id_pk'] . "" . fs_filehandler::NewLine();
            }
        }
        if (fs_filehandler::UpdateFile(ctrl_options::GetSystemOption('cron_file'), 0777, $line)) {
            return true;
        } else {
            return false;
        }
    }
}
 /**
  * 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;
 }
 static function ExecuteAddDomain($uid, $domain, $destination, $autohome)
 {
     global $zdbh;
     $retval = FALSE;
     runtime_hook::Execute('OnBeforeAddDomain');
     $currentuser = ctrl_users::GetUserDetail($uid);
     $domain = strtolower(str_replace(' ', '', $domain));
     if (!fs_director::CheckForEmptyValue(self::CheckCreateForErrors($domain))) {
         //** New Home Directory **//
         if ($autohome == 1) {
             $destination = "/" . str_replace(".", "_", $domain);
             $vhost_path = ctrl_options::GetSystemOption('hosted_dir') . $currentuser['username'] . "/public_html/" . $destination . "/";
             fs_director::CreateDirectory($vhost_path);
             fs_director::SetFileSystemPermissions($vhost_path, 0777);
             //** Existing Home Directory **//
         } else {
             $destination = "/" . $destination;
             $vhost_path = ctrl_options::GetSystemOption('hosted_dir') . $currentuser['username'] . "/public_html/" . $destination . "/";
         }
         // 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
         fs_director::CreateDirectory($vhost_path . "/_errorpages/");
         $errorpages = ctrl_options::GetSystemOption('static_dir') . "/errorpages/";
         if (is_dir($errorpages)) {
             if ($handle = @opendir($errorpages)) {
                 while (($file = @readdir($handle)) !== false) {
                     if ($file != "." && $file != "..") {
                         $page = explode(".", $file);
                         if (!fs_director::CheckForEmptyValue(self::CheckErrorDocument($page[0]))) {
                             fs_filehandler::CopyFile($errorpages . $file, $vhost_path . '/_errorpages/' . $file);
                         }
                     }
                 }
                 closedir($handle);
             }
         }
         // Lets copy the default welcome page across...
         if (!file_exists($vhost_path . "/index.html") && !file_exists($vhost_path . "/index.php") && !file_exists($vhost_path . "/index.htm")) {
             fs_filehandler::CopyFileSafe(ctrl_options::GetSystemOption('static_dir') . "pages/welcome.html", $vhost_path . "/index.html");
         }
         // If all has gone well we need to now create the domain in the database...
         $sql = $zdbh->prepare("INSERT INTO x_vhosts (vh_acc_fk,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t vh_name_vc,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t vh_directory_vc,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t vh_type_in,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t vh_created_ts) VALUES (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t :userid,\n\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 :destination,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t 1,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t :time)");
         //CLEANER FUNCTION ON $domain and $homedirectory_to_use (Think I got it?)
         $time = time();
         $sql->bindParam(':time', $time);
         $sql->bindParam(':userid', $currentuser['userid']);
         $sql->bindParam(':domain', $domain);
         $sql->bindParam(':destination', $destination);
         $sql->execute();
         // Only run if the Server platform is Windows.
         if (sys_versions::ShowOSPlatformVersion() == 'Windows') {
             if (ctrl_options::GetSystemOption('disable_hostsen') == 'false') {
                 // Lets add the hostname to the HOSTS file so that the server can view the domain immediately...
                 @exec("C:/Sentora/bin/zpss/setroute.exe " . $domain . "");
                 @exec("C:/Sentora/bin/zpss/setroute.exe www." . $domain . "");
             }
         }
         self::SetWriteApacheConfigTrue();
         $retval = TRUE;
         runtime_hook::Execute('OnAfterAddDomain');
         return $retval;
     }
 }
Exemple #7
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;
}
 public function __construct()
 {
     $this->osPlatformVersion = sys_versions::ShowOSPlatformVersion();
     $this->sentoraVersion = sys_versions::ShowSentoraVersion();
 }
 public static function Template()
 {
     return sys_versions::ShowMySQLVersion();
 }
function ReloadBindHook()
{
    if (sys_versions::ShowOSPlatformVersion() == "Windows") {
        $reload_bind = ctrl_options::GetSystemOption('bind_dir') . "rndc.exe reload";
    } else {
        $reload_bind = ctrl_options::GetSystemOption('zsudo') . " service " . ctrl_options::GetSystemOption('bind_service') . " reload";
    }
    echo "Reloading BIND now..." . fs_filehandler::NewLine();
    pclose(popen($reload_bind, 'r'));
}
 /**
  * Returns in human readable form the operating system name (eg. Windows, Ubuntu, CentOS, MacOSX, FreeBSD, Other)
  * @author Bobby Allen (ballen@bobbyallen.me)
  * @return string Human readable OS name.
  */
 static function ShowOSName()
 {
     preg_match_all("#(?<=\\()(.*?)(?=\\))#", $_SERVER['SERVER_SOFTWARE'], $osname);
     if (!empty($osname)) {
         if (strtoupper(substr($osname[0][0], 0, 3)) == "WIN") {
             $retval = "Windows";
         } else {
             $retval = $osname[0][0];
             if ($retval == "Unix") {
                 // Lets just make sure it isn't MacOSX before we give up!
                 if (sys_versions::ShowOSPlatformVersion() == "MacOSX") {
                     $retval = "MacOSX";
                 }
             }
         }
         //My testing shows Linux shows correct OS, WindowsXP=Win32, Windows2007/Server=WINNT -russ
         /*
          $uname = strtolower(php_uname());
          $retval = "";
          if (strpos($uname, "darwin") !== false) {
          $retval = "MacOSX";
          } else if (strpos($uname, "win") !== false) {
          $retval = "Windows";
          } else if (strpos($uname, "freebsd") !== false) {
          $retval = "FreeBSD";
          } else if (strpos($uname, "openbsd") !== false) {
          $retval = "OpenBSD";
          } else {
         */
         /**
          * @todo convert the bottom bit to read from a list of OS's.
          */
         /*
          $list = @parse_ini_file("lib/sentora/os.ini", true);
          foreach ($list as $section => $distribution) {
          if (!isset($distribution["Files"])) {
         
          } else {
          $intBytes = 4096;
          $intLines = 0;
          $intCurLine = 0;
          $strFile = "";
          foreach (preg_split("/;/", $distribution["Files"], -1, PREG_SPLIT_NO_EMPTY) as $filename) {
          if (file_exists($filename)) {
          if (isset($distribution["Name"])) {
          $os = $distribution["Name"];
          }
          }
          }
          if ($os == null) {
          $os = "Unknown";
          }
          }
          }
         */
     } else {
         $retval = "Unknown";
     }
     return $retval;
 }
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;
    }
}
 public static function Template()
 {
     return sys_versions::ShowOSName();
 }
 public function ExecuteAddParkedDomain($uid, $domain)
 {
     global $zdbh;
     $retval = FALSE;
     runtime_hook::Execute('OnBeforeAddParkedDomain');
     $currentuser = ctrl_users::GetUserDetail($uid);
     $domain = strtolower(str_replace(' ', '', $domain));
     if (!fs_director::CheckForEmptyValue(self::CheckCreateForErrors($domain))) {
         // If all has gone well we need to now create the domain in the database...
         $sql = $zdbh->prepare("INSERT INTO x_vhosts (vh_acc_fk,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t vh_name_vc,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t vh_directory_vc,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t vh_type_in,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t vh_created_ts) VALUES (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t :userid,\n\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 '',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t 3,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t :time)");
         $sql->bindParam(':userid', $currentuser['userid']);
         $sql->bindParam(':domain', $domain);
         $time = time();
         $sql->bindParam(':time', $time);
         $sql->execute();
         # Only run if the Server platform is Windows.
         if (sys_versions::ShowOSPlatformVersion() == 'Windows') {
             if (ctrl_options::GetSystemOption('disable_hostsen') == 'false') {
                 # Lets add the hostname to the HOSTS file so that the server can view the domain immediately...
                 @exec("C:/zpanel/bin/zpss/setroute.exe " . $domain . "");
                 @exec("C:/zpanel/bin/zpss/setroute.exe www." . $domain . "");
             }
         }
         self::SetWriteApacheConfigTrue();
         $retval = TRUE;
         runtime_hook::Execute('OnAfterAddParkedDomain');
         return $retval;
     }
 }
                    $versionsql->bindParam(':latest_version', $latest_version);
                    $versionsql->bindParam(':downloadurl', $downloadurl);
                    $versionsql->execute();
                } else {
                    $versionsql = $zdbh->prepare("UPDATE x_modules SET mo_updatever_vc = '', mo_updateurl_tx = '' WHERE mo_id_pk = :mo_id_pk");
                    $versionsql->bindParam(':mo_id_pk', $modules['mo_id_pk']);
                    $versionsql->execute();
                }
            } else {
                echo "The remote file was not parsed correctly or does not exist." . fs_filehandler::NewLine();
            }
        } else {
            echo "The remote file does not exist." . fs_filehandler::NewLine();
        }
    } else {
        echo "Couldn't open the module XML file for (" . $modules['mo_name_vc'] . ")" . fs_filehandler::NewLine();
    }
}
echo "END getting module version update information!" . fs_filehandler::NewLine();
/*
 * Please DO NOT remove the below code, this helps us at the ZPanel project
 * find out non-personal infomation about how people are running ZPanel. The only infomation
 * that we are passing back here is just your ZPanel version and what OS you are running it on.
 *
 * We also collec the email address of the default 'zadmin' account to enable automatic email
 * notficiations of new releases.
 */
$zdbh->bindQuery('SELECT ac_email_vc AS email FROM x_accounts WHERE ac_user_vc = :user', array(':user' => 'zadmin'));
$zadmin = $zdbh->returnRow();
ws_generic::DoPostRequest('http://api.sentora.io/hello.json', "version=" . sys_versions::ShowZpanelVersion() . "&platform=" . sys_versions::ShowOSPlatformVersion() . "&url=" . ctrl_options::GetSystemOption('zpanel_domain') . "mail=" . $zadmin['email']);
return true;
     //cd /var/sentora/hostdata/zadmin/; zip -r backups/backup.zip public_html/
     $resault = exec("cd " . $homedir . "/ && " . ctrl_options::GetSystemOption('zip_exe') . " -r9 " . ctrl_options::GetSystemOption('temp_dir') . $backupname . " public_html/*");
     @chmod(ctrl_options::GetSystemOption('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";
 if ($numrows = $zdbh->query($sql)) {
     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'] . " > " . ctrl_options::GetSystemOption('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 " . ctrl_options::GetSystemOption('temp_dir') . $backupname . ".zip " . ctrl_options::GetSystemOption('temp_dir') . $row_mysql['my_name_vc'] . "_" . $dbstamp . ".sql"));
             } else {
                 $resault = exec("cd " . ctrl_options::GetSystemOption('temp_dir') . "/ && " . ctrl_options::GetSystemOption('zip_exe') . " " . ctrl_options::GetSystemOption('temp_dir') . $backupname . "  " . $row_mysql['my_name_vc'] . "_" . $dbstamp . ".sql");
             }
             unlink(ctrl_options::GetSystemOption('temp_dir') . $row_mysql['my_name_vc'] . "_" . $dbstamp . ".sql");
         }
     }
 }
 // We have the backup now lets output it to disk or download
 if (file_exists(ctrl_options::GetSystemOption('temp_dir') . $backupname . ".zip")) {
     // Copy Backup to user home directory...
     $backupdir = $homedir . "/backups/";
     if (!is_dir($backupdir)) {
         mkdir($backupdir, 0777, TRUE);
     }
Exemple #17
0
 static function WriteCronFile()
 {
     global $zdbh;
     $currentuser = ctrl_users::GetUserDetail();
     $line = "";
     $sql = "SELECT * FROM x_cronjobs WHERE ct_deleted_ts IS NULL";
     $numrows = $zdbh->query($sql);
     //common header whatever there are some cron task or not
     if (sys_versions::ShowOSPlatformVersion() != "Windows") {
         $line .= 'SHELL=/bin/bash' . fs_filehandler::NewLine();
         $line .= 'PATH=/sbin:/bin:/usr/sbin:/usr/bin' . fs_filehandler::NewLine();
         $line .= 'HOME=/' . fs_filehandler::NewLine();
         $line .= fs_filehandler::NewLine();
     }
     $restrictinfos = ctrl_options::GetSystemOption('php_exer') . " -d suhosin.executor.func.blacklist=\"passthru, show_source, shell_exec, system, pcntl_exec, popen, pclose, proc_open, proc_nice, proc_terminate, proc_get_status, proc_close, leak, apache_child_terminate, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid, posix_setuid, escapeshellcmd, escapeshellarg, exec\" -d open_basedir=\"" . ctrl_options::GetSystemOption('hosted_dir') . $currentuser['username'] . "/" . ctrl_options::GetSystemOption('openbase_seperator') . ctrl_options::GetSystemOption('openbase_temp') . "\" ";
     $line .= "#################################################################################" . fs_filehandler::NewLine();
     $line .= "# CRONTAB FOR MADmin CRON MANAGER MODULE                                        " . fs_filehandler::NewLine();
     $line .= "# Module Developed by Bobby Allen, 17/12/2009                                    " . fs_filehandler::NewLine();
     $line .= "# File automatically generated by MADmin " . sys_versions::ShowMADminVersion() . fs_filehandler::NewLine();
     if (sys_versions::ShowOSPlatformVersion() == "Windows") {
         $line .= "# Cron Debug infomation can be found in file C:\\WINDOWS\\System32\\crontab.txt " . fs_filehandler::NewLine();
         $line .= "#################################################################################" . fs_filehandler::NewLine();
         $line .= "" . ctrl_options::GetSystemOption('daemon_timing') . " " . $restrictinfos . ctrl_options::GetSystemOption('daemon_exer') . fs_filehandler::NewLine();
     }
     $line .= "#################################################################################" . fs_filehandler::NewLine();
     $line .= "# NEVER MANUALLY REMOVE OR EDIT ANY OF THE CRON ENTRIES FROM THIS FILE,          " . fs_filehandler::NewLine();
     $line .= "#  -> USE MADmin INSTEAD! (Menu -> Advanced -> Cron Manager)                    " . fs_filehandler::NewLine();
     $line .= "#################################################################################" . fs_filehandler::NewLine();
     //Write command lines in crontab, if any
     if ($numrows->fetchColumn() != 0) {
         $sql = $zdbh->prepare($sql);
         $sql->execute();
         while ($rowcron = $sql->fetch()) {
             $fetchRows = $zdbh->prepare("SELECT * FROM x_accounts WHERE ac_id_pk=:userid AND ac_deleted_ts IS NULL");
             $fetchRows->bindParam(':userid', $rowcron['ct_acc_fk']);
             $fetchRows->execute();
             $rowclient = $fetchRows->fetch();
             if ($rowclient && $rowclient['ac_enabled_in'] != 0) {
                 $line .= "# CRON ID: " . $rowcron['ct_id_pk'] . fs_filehandler::NewLine();
                 $line .= $rowcron['ct_timing_vc'] . " " . $restrictinfos . $rowcron['ct_fullpath_vc'] . fs_filehandler::NewLine();
                 $line .= "# END CRON ID: " . $rowcron['ct_id_pk'] . fs_filehandler::NewLine();
             }
         }
     }
     if (fs_filehandler::UpdateFile(ctrl_options::GetSystemOption('cron_file'), 0644, $line)) {
         if (sys_versions::ShowOSPlatformVersion() != "Windows") {
             $returnValue = ctrl_system::systemCommand(ctrl_options::GetSystemOption('zsudo'), array(ctrl_options::GetSystemOption('cron_reload_command'), ctrl_options::GetSystemOption('cron_reload_flag'), ctrl_options::GetSystemOption('cron_reload_user'), ctrl_options::GetSystemOption('cron_reload_path')));
         }
         return true;
     } else {
         return false;
     }
 }
                    $versionsql->bindParam(':mo_id_pk', $modules['mo_id_pk']);
                    $versionsql->bindParam(':latest_version', $latest_version);
                    $versionsql->bindParam(':downloadurl', $downloadurl);
                    $versionsql->execute();
                } else {
                    $versionsql = $zdbh->prepare("UPDATE x_modules SET mo_updatever_vc = '', mo_updateurl_tx = '' WHERE mo_id_pk = :mo_id_pk");
                    $versionsql->bindParam(':mo_id_pk', $modules['mo_id_pk']);
                    $versionsql->execute();
                }
            } else {
                echo "The remote file was not parsed correctly or does not exist." . fs_filehandler::NewLine();
            }
        } else {
            echo "The remote file does not exist." . fs_filehandler::NewLine();
        }
    } else {
        echo "Couldn't open the module XML file for (" . $modules['mo_name_vc'] . ")" . fs_filehandler::NewLine();
    }
}
echo "END getting module version update information!" . fs_filehandler::NewLine();
/*
 * Please DO NOT remove the below code, this helps us at the MADmin project
 * find out non-personal infomation about how people are running MADmin. The only infomation
 * that we are passing back here is your MADmin version and what OS you are running it on in addition
 * to collecting the email address of the default 'zadmin' account to enable automatic email
 * notficiations of new releases and urgent patches.
 */
$zdbh->bindQuery('SELECT ac_email_vc AS email FROM x_accounts WHERE ac_user_vc = :user', array(':user' => 'zadmin'));
$zadmin = $zdbh->returnRow();
ws_generic::DoPostRequest('http://api.MADmin.org/hello.json', "version=" . sys_versions::ShowMADminVersion() . "&platform=" . sys_versions::ShowOSPlatformVersion() . "&url=" . ctrl_options::GetSystemOption('MADmin_domain') . "mail=" . $zadmin['email']);
return true;
 public static function Template()
 {
     return sys_versions::ShowApacheVersion();
 }
 static function SetPerms()
 {
     $bindlog = ctrl_options::GetSystemOption('bind_log');
     if (sys_versions::ShowOSPlatformVersion() != "Windows") {
         //exec(ctrl_options::GetOption('zsudo') . " chgrp " . ctrl_options::GetOption('zsudo') . " " . $bindlog);
         exec(ctrl_options::GetSystemOption('zsudo') . " chmod 0777 " . $bindlog);
     }
 }
 /**
  * Creates the correct line ending based on the server OS platform.
  * @author Russell Skinner (rskinner@zpanelcp.com)
  * @return string The correct line ending charater.
  */
 static function NewLine()
 {
     if (sys_versions::ShowOSPlatformVersion() == "Windows") {
         $retval = "\r\n";
     } else {
         $retval = "\n";
     }
     return $retval;
 }
 public static function Template()
 {
     return sys_versions::ShowZpanelVersion();
 }
Exemple #23
0
 static function DisplayUsagepChart()
 {
     global $zdbh;
     global $controller;
     $currentuser = ctrl_users::GetUserDetail();
     self::$diskquota = $currentuser['diskquota'];
     self::$diskspace = ctrl_users::GetQuotaUsages('diskspace', $currentuser['userid']);
     self::$bandwidthquota = module_controller::empty_as_0($currentuser['bandwidthquota']);
     self::$bandwidth = ctrl_users::GetQuotaUsages('bandwidth', $currentuser['userid']);
     self::$domainsquota = module_controller::empty_as_0($currentuser['domainquota']);
     self::$domains = ctrl_users::GetQuotaUsages('domains', $currentuser['userid']);
     self::$subdomainsquota = module_controller::empty_as_0($currentuser['subdomainquota']);
     self::$subdomains = ctrl_users::GetQuotaUsages('subdomains', $currentuser['userid']);
     self::$parkeddomainsquota = module_controller::empty_as_0($currentuser['parkeddomainquota']);
     self::$parkeddomains = ctrl_users::GetQuotaUsages('parkeddomains', $currentuser['userid']);
     self::$mysqlquota = module_controller::empty_as_0($currentuser['mysqlquota']);
     self::$mysql = ctrl_users::GetQuotaUsages('mysql', $currentuser['userid']);
     self::$ftpaccountsquota = module_controller::empty_as_0($currentuser['ftpaccountsquota']);
     self::$ftpaccounts = ctrl_users::GetQuotaUsages('ftpaccounts', $currentuser['userid']);
     self::$mailboxquota = module_controller::empty_as_0($currentuser['mailboxquota']);
     self::$mailboxes = ctrl_users::GetQuotaUsages('mailboxes', $currentuser['userid']);
     self::$forwardersquota = module_controller::empty_as_0($currentuser['forwardersquota']);
     self::$forwarders = ctrl_users::GetQuotaUsages('forwarders', $currentuser['userid']);
     self::$distlistsquota = $currentuser['distlistsquota'];
     self::$distlists = module_controller::empty_as_0(ctrl_users::GetQuotaUsages('distlists', $currentuser['userid']));
     $maximum = self::$diskquota;
     $used = self::$diskspace;
     if ($maximum == 0) {
         if (sys_versions::ShowOSPlatformVersion() != 'Windows') {
             // We'll specify the full path to the hsoted directory to ensure that NFS mounts etc are taken into account.
             $free = disk_free_space(ctrl_options::GetOption('hosted_dir'));
         } else {
             // On Windows we'll check the disk (partition) that is configured for the 'hostdata' directory.
             $free = disk_free_space(substr(ctrl_options::GetOption('hosted_dir'), 0, 2));
         }
         $freeLabel = fs_director::ShowHumanFileSize($free) . ' (' . ui_language::translate('Server disk') . ')';
     } else {
         $free = max($maximum - $used, 0);
         $freeLabel = fs_director::ShowHumanFileSize($free);
     }
     $usedLabel = fs_director::ShowHumanFileSize($used);
     $line = '<table class="none" cellpadding="0" cellspacing="0">' . '<tr>' . '<td align="left" valign="top" width="350px">' . '<h2>' . ui_language::translate('Disk Usage Total') . '</h2>' . '<img src="etc/lib/pChart2/MADmin/z3DPie.php?score=' . $free . '::' . $used . '&amp;imagesize=350::250&amp;chartsize=150::120&amp;radius=150' . '&amp;labels=Free_Space: ' . $freeLabel . '::Used_Space: ' . $usedLabel . '&amp;legendfont=verdana&amp;legendfontsize=8&amp;legendsize=10::220"/>' . '</td>' . '<td align="left" valign="top">' . '<h2>' . ui_language::translate('Package Usage Total') . '</h2>' . '<table class="table table-striped" border="0" cellspacing="0" cellpadding="0">' . module_controller::build_row_usage('Disk space', self::$diskspace, self::$diskquota == 0 ? -1 : self::$diskquota, true) . module_controller::build_row_usage('Bandwidth', self::$bandwidth, self::$bandwidthquota == 0 ? -1 : self::$bandwidthquota, true) . module_controller::build_row_usage('Domains', self::$domains, self::$domainsquota) . module_controller::build_row_usage('Sub-domains', self::$subdomains, self::$subdomainsquota) . module_controller::build_row_usage('Parked domains', self::$parkeddomains, self::$parkeddomainsquota) . module_controller::build_row_usage('FTP accounts', self::$ftpaccounts, self::$ftpaccountsquota) . module_controller::build_row_usage('MySQL&reg databases', self::$mysql, self::$mysqlquota) . module_controller::build_row_usage('Mailboxes', self::$mailboxes, self::$mailboxquota) . module_controller::build_row_usage('Mail forwarders', self::$forwarders, self::$forwardersquota) . module_controller::build_row_usage('Distribution lists', self::$distlists, self::$distlistsquota) . '</table>' . '</td>' . '</tr>' . '</table>';
     return $line;
 }
 public static function Template()
 {
     return sys_versions::ShowSentoraVersion();
 }
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;
    }
}
 static function WriteCronFile()
 {
     global $zdbh;
     $currentuser = ctrl_users::GetUserDetail();
     $line = "";
     $sql = "SELECT * FROM x_cronjobs WHERE ct_deleted_ts IS NULL";
     $numrows = $zdbh->query($sql);
     if ($numrows->fetchColumn() != 0) {
         $sql = $zdbh->prepare($sql);
         $sql->execute();
         $line .= "#################################################################################" . fs_filehandler::NewLine();
         $line .= "# CRONTAB FOR ZPANEL CRON MANAGER MODULE                                         " . fs_filehandler::NewLine();
         $line .= "# Module Developed by Bobby Allen, 17/12/2009                                    " . fs_filehandler::NewLine();
         $line .= "# Automatically generated by Sentora " . sys_versions::ShowSentoraVersion() . "      " . fs_filehandler::NewLine();
         $line .= "#################################################################################" . fs_filehandler::NewLine();
         $line .= "# WE DO NOT RECOMMEND YOU MODIFY THIS FILE DIRECTLY, PLEASE USE ZPANEL INSTEAD!  " . fs_filehandler::NewLine();
         $line .= "#################################################################################" . fs_filehandler::NewLine();
         if (sys_versions::ShowOSPlatformVersion() == "Windows") {
             $line .= "# Cron Debug infomation can be found in this file here:-                        " . fs_filehandler::NewLine();
             $line .= "# C:\\WINDOWS\\System32\\crontab.txt                                                " . fs_filehandler::NewLine();
             $line .= "#################################################################################" . fs_filehandler::NewLine();
             // removed openbase_dir and suhosin directives from daemon run - daemon now runs just fine on windows
             //$line .= "" . ctrl_options::GetSystemOption('daemon_timing') . " " . ctrl_options::GetSystemOption('php_exer') . " -d suhosin.executor.func.blacklist=\"passthru, show_source, shell_exec, system, pcntl_exec, popen, pclose, proc_open, proc_nice, proc_terminate, proc_get_status, proc_close, leak, apache_child_terminate, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid, posix_setuid, escapeshellcmd, escapeshellarg, exec\" -d open_basedir=\"" . ctrl_options::GetSystemOption('hosted_dir') . $currentuser['username'] . "/" . ctrl_options::GetSystemOption('openbase_seperator') . ctrl_options::GetSystemOption('openbase_temp') . "\" " . ctrl_options::GetSystemOption('daemon_exer') . "" . fs_filehandler::NewLine();
             $line .= "" . ctrl_options::GetSystemOption('daemon_timing') . " " . ctrl_options::GetSystemOption('php_exer') . " " . ctrl_options::GetSystemOption('daemon_exer') . "" . fs_filehandler::NewLine();
             $line .= "#################################################################################" . fs_filehandler::NewLine();
         }
         $line .= "# DO NOT MANUALLY REMOVE ANY OF THE CRON ENTRIES FROM THIS FILE, USE ZPANEL      " . fs_filehandler::NewLine();
         $line .= "# INSTEAD! THE ABOVE ENTRIES ARE USED FOR ZPANEL TASKS, DO NOT REMOVE THEM!      " . fs_filehandler::NewLine();
         $line .= "#################################################################################" . fs_filehandler::NewLine();
         while ($rowcron = $sql->fetch()) {
             $fetchRows = $zdbh->prepare("SELECT * FROM x_accounts WHERE ac_id_pk=:userid AND ac_deleted_ts IS NULL");
             $fetchRows->bindParam(':userid', $rowcron['ct_acc_fk']);
             $fetchRows->execute();
             $rowclient = $fetchRows->fetch();
             if ($rowclient && $rowclient['ac_enabled_in'] != 0) {
                 $line .= "# CRON ID: " . $rowcron['ct_id_pk'] . "" . fs_filehandler::NewLine();
                 // removed openbase_dir and suhosin directives - allows proper running of jobs on Windows
                 //$line .= "" . $rowcron['ct_timing_vc'] . " " . ctrl_options::GetSystemOption('php_exer') . " -d suhosin.executor.func.blacklist=\"passthru, show_source, shell_exec, system, pcntl_exec, popen, pclose, proc_open, proc_nice, proc_terminate, proc_get_status, proc_close, leak, apache_child_terminate, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid, posix_setuid, escapeshellcmd, escapeshellarg, exec\" -d open_basedir=\"" . ctrl_options::GetSystemOption('hosted_dir') . $currentuser['username'] . "/" . ctrl_options::GetSystemOption('openbase_seperator') . ctrl_options::GetSystemOption('openbase_temp') . "\" " . $rowcron['ct_fullpath_vc'] . "" . fs_filehandler::NewLine();
                 $line .= "" . $rowcron['ct_timing_vc'] . " " . ctrl_options::GetSystemOption('php_exer') . " " . $rowcron['ct_fullpath_vc'] . "" . fs_filehandler::NewLine();
                 $line .= "# END CRON ID: " . $rowcron['ct_id_pk'] . "" . fs_filehandler::NewLine();
             }
         }
         if (fs_filehandler::UpdateFile(ctrl_options::GetSystemOption('cron_file'), 0644, $line)) {
             if (sys_versions::ShowOSPlatformVersion() != "Windows") {
                 $returnValue = ctrl_system::systemCommand(ctrl_options::GetSystemOption('zsudo'), array(ctrl_options::GetSystemOption('cron_reload_command'), ctrl_options::GetSystemOption('cron_reload_flag'), ctrl_options::GetSystemOption('cron_reload_user'), ctrl_options::GetSystemOption('cron_reload_path')));
                 //var_dump( $returnValue );
             }
             return true;
         } else {
             return false;
         }
     } else {
         $line .= "#################################################################################" . fs_filehandler::NewLine();
         $line .= "# CRONTAB FOR ZPANEL CRON MANAGER MODULE                                         " . fs_filehandler::NewLine();
         $line .= "# Module Developed by Bobby Allen, 17/12/2009                                    " . fs_filehandler::NewLine();
         $line .= "# Automatically generated by Sentora " . sys_versions::ShowSentoraVersion() . "      " . fs_filehandler::NewLine();
         $line .= "#################################################################################" . fs_filehandler::NewLine();
         $line .= "# WE DO NOT RECOMMEND YOU MODIFY THIS FILE DIRECTLY, PLEASE USE ZPANEL INSTEAD!  " . fs_filehandler::NewLine();
         $line .= "#################################################################################" . fs_filehandler::NewLine();
         if (sys_versions::ShowOSPlatformVersion() == "Windows") {
             $line .= "# Cron Debug infomation can be found in this file here:-                        " . fs_filehandler::NewLine();
             $line .= "# C:\\WINDOWS\\System32\\crontab.txt                                                " . fs_filehandler::NewLine();
             $line .= "#################################################################################" . fs_filehandler::NewLine();
             $line .= "" . ctrl_options::GetSystemOption('daemon_timing') . " " . ctrl_options::GetSystemOption('php_exer') . " " . ctrl_options::GetSystemOption('daemon_exer') . "" . fs_filehandler::NewLine();
             $line .= "#################################################################################" . fs_filehandler::NewLine();
         }
         $line .= "# DO NOT MANUALLY REMOVE ANY OF THE CRON ENTRIES FROM THIS FILE, USE ZPANEL      " . fs_filehandler::NewLine();
         $line .= "# INSTEAD! THE ABOVE ENTRIES ARE USED FOR ZPANEL TASKS, DO NOT REMOVE THEM!      " . fs_filehandler::NewLine();
         $line .= "#################################################################################" . fs_filehandler::NewLine();
         if (fs_filehandler::UpdateFile(ctrl_options::GetSystemOption('cron_file'), 0644, $line)) {
             if (sys_versions::ShowOSPlatformVersion() != "Windows") {
                 $returnValue = ctrl_system::systemCommand(ctrl_options::GetSystemOption('zsudo'), array(ctrl_options::GetSystemOption('cron_reload_command'), ctrl_options::GetSystemOption('cron_reload_flag'), ctrl_options::GetSystemOption('cron_reload_user'), ctrl_options::GetSystemOption('cron_reload_path')));
                 //var_dump( $returnValue );
             }
             return true;
         } else {
             return false;
         }
     }
 }