static function doUpdateConfig()
 {
     global $zdbh;
     global $controller;
     runtime_csfr::Protect();
     $sql = "SELECT * FROM x_settings WHERE so_module_vc=:name AND so_usereditable_en = 'true'";
     //$numrows = $zdbh->query($sql);
     $name = ui_module::GetModuleName();
     $numrows = $zdbh->prepare($sql);
     $numrows->bindParam(':name', $name);
     $numrows->execute();
     if ($numrows->fetchColumn() != 0) {
         $sql = $zdbh->prepare($sql);
         $sql->bindParam(':name', $name);
         $sql->execute();
         while ($row = $sql->fetch()) {
             if (!fs_director::CheckForEmptyValue($controller->GetControllerRequest('FORM', $row['so_name_vc']))) {
                 $updatesql = $zdbh->prepare("UPDATE x_settings SET so_value_tx = :name2 WHERE so_name_vc = :so_name_vc");
                 $name2 = $controller->GetControllerRequest('FORM', $row['so_name_vc']);
                 $updatesql->bindParam(':name2', $name2);
                 $updatesql->bindParam(':so_name_vc', $row['so_name_vc']);
                 $updatesql->execute();
             }
         }
     }
     self::$ok = true;
 }
 public static function Template()
 {
     global $controller;
     if ($controller->GetControllerRequest('URL', 'module')) {
         return ui_module::getModule($controller->getCurrentModule());
     }
 }
 /**
  * Get the latest requests and updates the values avaliable to the model/view.
  * @author Bobby Allen (ballen@bobbyallen.me)
  */
 public function Init()
 {
     //Set class varables
     $this->vars_get = array($_GET);
     $this->vars_post = array($_POST);
     $this->vars_session = array($_SESSION);
     $this->vars_cookie = array($_COOKIE);
     //Here we get the users information
     $user = ctrl_users::GetUserDetail();
     if (!isset($this->vars_session[0]['zpuid'])) {
         ui_module::GetLoginTemplate();
     }
     if (isset($this->vars_get[0]['module'])) {
         ui_module::getModule($this->GetCurrentModule());
     }
     if (isset($this->vars_get[0]['action'])) {
         if (ctrl_groups::CheckGroupModulePermissions($user['usergroupid'], ui_module::GetModuleID())) {
             if (class_exists('module_controller', FALSE) && method_exists('module_controller', 'do' . $this->vars_get[0]['action'])) {
                 call_user_func(array('module_controller', 'do' . $this->vars_get[0]['action']));
             } else {
                 echo ui_sysmessage::shout("No 'do" . runtime_xss::xssClean($this->vars_get[0]['action']) . "' class exists - Please create it to enable controller actions and runtime placeholders within your module.");
             }
         }
     }
     return;
 }
 public static function Template()
 {
     global $zdbh, $controller;
     $line = '';
     if ($controller->GetControllerRequest('URL', 'module')) {
         $module = $controller->GetControllerRequest('URL', 'module');
         $moduleRow = ui_module::GetModuleCategoryName();
         $catUrl = strtolower(str_replace(' ', '-', $moduleRow['mc_name_vc']));
         if ($moduleRow) {
             $line .= '<ul class="breadcrumb">';
             $line .= '  <li><a href=".">Home</a></li>';
             $line .= '  <li><a href="./#' . $catUrl . '">' . $moduleRow['mc_name_vc'] . '</a></li>';
             $line .= '  <li class="active">' . $moduleRow['mo_name_vc'] . '</li>';
             $line .= '</ul>';
         }
     }
     return $line;
 }
    static function getCopyright()
    {
        $message = '<font face="ariel" size="2">' . ui_module::GetModuleName() . ' v20.2.0.0 &copy; 2013-' . date("Y") . ' by <a target="_blank" href="http://forums.sentora.org/member.php?action=profile&uid=2">TGates</a> for <a target="_blank" href="http://sentora.org">Sentora Control Panel</a>&nbsp;&#8212;&nbsp;Help support future development of this module and donate today!</font>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="DW8QTHWW4FMBY">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif" width="70" height="21" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>';
        return $message;
    }
<?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';
 static function getModuleName()
 {
     $module_name = ui_language::translate(ui_module::GetModuleName());
     return $module_name;
 }
 static function doUpdateDNSConfig()
 {
     global $zdbh;
     global $controller;
     $sql = "SELECT COUNT(*) FROM x_settings WHERE so_module_vc=:moduleName AND so_usereditable_en = 'true'";
     $numrows = $zdbh->prepare($sql);
     $GetModuleName = ui_module::GetModuleName();
     $numrows->bindParam(':moduleName', $GetModuleName);
     if ($numrows->execute()) {
         if ($numrows->fetchColumn() != 0) {
             $sql = $zdbh->prepare("SELECT * FROM x_settings WHERE so_module_vc=:moduleName AND so_usereditable_en = 'true'");
             $GetModuleName = ui_module::GetModuleName();
             $sql->bindParam(':moduleName', $GetModuleName);
             $sql->execute();
             while ($row = $sql->fetch()) {
                 if (!fs_director::CheckForEmptyValue($controller->GetControllerRequest('FORM', $row['so_name_vc']))) {
                     $name = $controller->GetControllerRequest('FORM', $row['so_name_vc']);
                     $name2 = $row['so_name_vc'];
                     $updatesql = $zdbh->prepare("UPDATE x_settings SET so_value_tx = :name WHERE so_name_vc = :name2");
                     $updatesql->bindParam(':name', $name);
                     $updatesql->bindParam(':name2', $name2);
                     $updatesql->execute();
                     self::TriggerDNSUpdate("0");
                 }
             }
         }
     }
 }
<?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());
 static function doUpdateConfig()
 {
     global $zdbh;
     global $controller;
     runtime_csfr::Protect();
     $sql = "SELECT * FROM x_settings WHERE so_module_vc=:module AND so_usereditable_en = 'true'";
     $module = ui_module::GetModuleName();
     $numrows = $zdbh->prepare($sql);
     $numrows->bindParam(':module', $module);
     $numrows->execute();
     if ($numrows->fetchColumn() <> 0) {
         $sql = $zdbh->prepare($sql);
         $sql->bindParam(':module', $module);
         $sql->execute();
         while ($row = $sql->fetch()) {
             if (!fs_director::CheckForEmptyValue($controller->GetControllerRequest('FORM', $row['so_name_vc']))) {
                 $updatesql = $zdbh->prepare("UPDATE x_settings SET so_value_tx = :value WHERE so_name_vc = :so_name_vc");
                 $value = $controller->GetControllerRequest('FORM', $row['so_name_vc']);
                 $updatesql->bindParam(':value', $value);
                 $updatesql->bindParam(':so_name_vc', $row['so_name_vc']);
                 $updatesql->execute();
             }
         }
         self::SetWriteApacheConfigTrue(); #sentora apache port changed require rewrite of vhosts
     }
     self::$ok = true;
 }
Exemple #11
0
 /**
  * Returns the modules description, this is pretty standard and by default is taken from the module description in the module table but
  * is designed to be overwritten in the module_controller class if a different alternative is required.
  * @return type
  */
 public static function getModuleDesc()
 {
     $module_desc = ui_language::translate(ui_module::GetModuleDescription());
     return $module_desc;
 }
 static function getModuleDesc()
 {
     $message = ui_language::translate(ui_module::GetModuleDescription());
     return $message;
 }
 /**
  * Get the current version of the module
  * @return string Version number
  */
 static function getVersion()
 {
     $tags = ui_module::GetModuleXMLTags('whmcs');
     return $tags['version'];
 }
Exemple #14
0
 /**
  * This class scans the module directory and will return an array of new modules that are not yet in the database.
  * @author Bobby Allen (ballen@bobbyallen.me)
  * @global db_driver $zdbh The ZPX database handle.
  * @param boolean $init Upon finding modules that don't exist in the database, add them!
  * @return array List of all new modules.
  */
 static function ScanForNewModules($init = false)
 {
     global $zdbh;
     $new_module_list = array();
     $handle = @opendir(ctrl_options::GetSystemOption('zpanel_root') . "modules");
     $chkdir = ctrl_options::GetSystemOption('zpanel_root') . "modules/";
     if ($handle) {
         while ($file = readdir($handle)) {
             if ($file != "." && $file != "..") {
                 if (is_dir($chkdir . $file)) {
                     $sql = $zdbh->prepare("SELECT mo_id_pk FROM x_modules WHERE mo_folder_vc = :file");
                     $sql->bindParam(':file', $file);
                     $status = $sql->execute();
                     $match_module = $sql->fetch();
                     if (!$match_module) {
                         array_push($new_module_list, $file);
                     }
                 }
             }
         }
         closedir($handle);
     }
     if ($init == true) {
         foreach ($new_module_list as $modules_to_import) {
             ui_module::ModuleInfoToDB($modules_to_import);
         }
     }
     return $new_module_list;
 }
<?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'] . "")) {
 static function getModuleName()
 {
     $module_name = ui_module::GetModuleName();
     return $module_name;
 }
<?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'];
    }
 static function doInstallModule()
 {
     self::$error_message = "";
     self::$error = false;
     if ($_FILES['modulefile']['error'] > 0) {
         self::$error_message = "Couldn't upload the file, " . $_FILES['modulefile']['error'] . "";
     } else {
         $archive_ext = fs_director::GetFileExtension($_FILES['modulefile']['name']);
         $module_folder = fs_director::GetFileNameNoExtentsion($_FILES['modulefile']['name']);
         $module_dir = ctrl_options::GetSystemOption('sentora_root') . 'modules/' . $module_folder;
         if (!fs_director::CheckFolderExists($module_dir)) {
             if ($archive_ext != 'zpp') {
                 self::$error_message = "Package type was not detected as a .zpp (Sentora Package) archive.";
             } else {
                 if (fs_director::CreateDirectory($module_dir)) {
                     if (sys_archive::Unzip($_FILES['modulefile']['tmp_name'], $module_dir . '/')) {
                         if (!fs_director::CheckFileExists($module_dir . '/module.xml')) {
                             self::$error_message = "No module.xml file found in the unzipped archive.";
                         } else {
                             ui_module::ModuleInfoToDB($module_folder);
                             $extra_config = $module_dir . "/deploy/install.run";
                             if (fs_director::CheckFileExists($extra_config)) {
                                 exec(ctrl_options::GetSystemOption('php_exer') . " " . $extra_config . "");
                             }
                             self::$ok = true;
                         }
                     } else {
                         self::$error_message = "Couldn't unzip the archive (" . $_FILES['modulefile']['tmp_name'] . ") to " . $module_dir . '/';
                     }
                 } else {
                     self::$error_message = "Couldn't create module folder in " . $module_dir;
                 }
             }
         } else {
             self::$error_message = "The module " . $module_folder . " is already installed on this server!";
         }
     }
     return;
 }
<?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)
{
 static function getResult()
 {
     if (!fs_director::CheckForEmptyValue(self::$ok)) {
         return ui_sysmessage::shout(ui_language::translate("Changes to your settings have been saved successfully!"));
     } else {
         return ui_language::translate(ui_module::GetModuleDescription());
     }
     return;
 }