<?php

echo fs_filehandler::NewLine() . "START Apache Config Hook." . fs_filehandler::NewLine();
if (ui_module::CheckModuleEnabled('Apache Config')) {
    echo "Apache Admin module ENABLED..." . fs_filehandler::NewLine();
    TriggerApacheQuotaUsage();
    if (ctrl_options::GetSystemOption('apache_changed') == strtolower("true")) {
        echo "Apache Config has changed..." . fs_filehandler::NewLine();
        if (ctrl_options::GetSystemOption('apache_backup') == strtolower("true")) {
            echo "Backing up Apache Config to: " . ctrl_options::GetSystemOption('apache_budir') . fs_filehandler::NewLine();
            BackupVhostConfigFile();
        }
        echo "Begin writing Apache Config to: " . ctrl_options::GetSystemOption('apache_vhost') . fs_filehandler::NewLine();
        WriteVhostConfigFile();
    } else {
        echo "Apache Config has NOT changed...nothing to do." . fs_filehandler::NewLine();
    }
} else {
    echo "Apache Admin module DISABLED...nothing to do." . fs_filehandler::NewLine();
}
echo "END Apache Config Hook." . fs_filehandler::NewLine();
/**
 *
 * @param string $vhostName
 * @param numeric $customPort
 * @param string $userEmail
 * @return string
 *
 */
function BuildVhostPortForward($vhostName, $customPort, $userEmail)
{
<?php

echo fs_filehandler::NewLine() . "START DNS Manager Hook" . fs_filehandler::NewLine();
if (ui_module::CheckModuleEnabled('DNS Config')) {
    echo "DNS Manager module ENABLED..." . fs_filehandler::NewLine();
    if (!fs_director::CheckForEmptyValue(ctrl_options::GetSystemOption('dns_hasupdates'))) {
        echo "DNS Records have changed... Writing new/updated records..." . fs_filehandler::NewLine();
        WriteDNSZoneRecordsHook();
        WriteDNSNamedHook();
        ResetDNSRecordsUpatedHook();
        PurgeOldZoneDNSRecordsHook();
        ReloadBindHook();
    } else {
        echo "DNS Records have not changed...nothing to do." . fs_filehandler::NewLine();
    }
} else {
    echo "DNS Manager module DISABLED...nothing to do." . fs_filehandler::NewLine();
}
echo "END DNS Manager Hook." . fs_filehandler::NewLine();
function WriteDNSZoneRecordsHook()
{
    global $zdbh;
    //Get list of domains id that have rows in the DNS table
    $DomainsNeedingUpdate = explode(",", ctrl_options::GetSystemOption('dns_hasupdates'));
    //Get list of domains id that have rows in the dns table
    $DomainsInDnsTable = array();
    $sql = $zdbh->prepare("SELECT dn_vhost_fk FROM x_dns WHERE dn_deleted_ts IS NULL GROUP BY dn_vhost_fk");
    $sql->execute();
    while ($rowdns = $sql->fetch()) {
        $DomainsInDnsTable[] = $rowdns['dn_vhost_fk'];
    }
<?php

include 'cnf/db.php';
$z_db_user = $user;
$z_db_pass = $pass;
$z_db_host = $host;
$z_db_name = $dbname;
try {
    $zdbh = new db_driver("mysql:host=" . $z_db_host . ";dbname=" . $z_db_name . "", $z_db_user, $z_db_pass);
} catch (PDOException $e) {
}
echo fs_filehandler::NewLine() . "START Backup Config." . fs_filehandler::NewLine();
if (ui_module::CheckModuleEnabled('Backup Config')) {
    echo "Backup Config module ENABLED..." . fs_filehandler::NewLine();
    // Schedule daily backups are enabled...
    if (strtolower(ctrl_options::GetSystemOption('schedule_bu')) == "true") {
        runtime_hook::Execute('OnBeforeScheduleBackup');
        echo "Backup Scheduling enabled - Backing up all enabled client files now..." . fs_filehandler::NewLine();
        // Get all accounts
        $bsql = "SELECT * FROM x_accounts WHERE ac_enabled_in=1 AND ac_deleted_ts IS NULL";
        $numrows = $zdbh->query($bsql);
        if ($numrows->fetchColumn() != 0) {
            $bsql = $zdbh->prepare($bsql);
            $bsql->execute();
            while ($rowclients = $bsql->fetch()) {
                echo "Backing up client folder: " . $rowclients['ac_user_vc'] . "/public_html..." . fs_filehandler::NewLine();
                // User loop
                $username = $rowclients['ac_user_vc'];
                $userid = $rowclients['ac_id_pk'];
                $homedir = ctrl_options::GetSystemOption('hosted_dir') . $username;
                //$backupname = $username . "_" . date("M-d-Y_hms", time());
<?php

/**
 * @copyright 2014-2015 MADmin Project (http://www.MADmin.org/) 
 * MADmin is a GPL fork of the ZPanel Project whose original header follows:
 *
 * ZPanel - Visitor Stats zpanel plugin, written by RusTus: www.zpanelcp.com.
 *
 * changes P;Peyremorte : reduced duplicate strings constructions
 */
echo fs_filehandler::NewLine() . "BEGIN Webalizer Stats" . fs_filehandler::NewLine();
if (ui_module::CheckModuleEnabled('Webalizer Stats')) {
    GenerateWebalizerStats();
} else {
    echo "Webalizer Stats Module DISABLED." . fs_filehandler::NewLine();
}
echo "END Webalizer Stats" . fs_filehandler::NewLine();
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';
<?php

/**
 * @copyright 2014-2015 Sentora Project (http://www.sentora.org/) 
 * Sentora is a GPL fork of the ZPanel Project whose original header follows:
 *
 *
 * Sentora - Visitor Stats sentora plugin, written by RusTus: www.sentora.org.
 *
 */
echo fs_filehandler::NewLine() . "BEGIN VISITOR STATS" . fs_filehandler::NewLine();
if (ui_module::CheckModuleEnabled('Visitor Stats')) {
    GenerateVisitorStats();
} else {
    echo "Visitor Stats Module DISABLED." . fs_filehandler::NewLine();
}
echo "END VISITOR STATS" . 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'] . "")) {