Example #1
0
 public function initAccount($certrow)
 {
     // Let's see if we have the private accountkey
     $this->accountKey = $certrow['leprivatekey'];
     if (!$this->accountKey || $this->accountKey == 'unset' || Settings::Get('system.letsencryptca') != 'production') {
         // generate and save new private key for account
         // ---------------------------------------------
         $this->log('Starting new account registration');
         $keys = $this->generateKey();
         // Only store the accountkey in production, in staging always generate a new key
         if (Settings::Get('system.letsencryptca') == 'production') {
             $upd_stmt = Database::prepare("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `lepublickey` = :public, `leprivatekey` = :private " . "WHERE `customerid` = :customerid;");
             Database::pexecute($upd_stmt, array('public' => $keys['public'], 'private' => $keys['private'], 'customerid' => $certrow['customerid']));
         }
         $this->accountKey = $keys['private'];
         $response = $this->postNewReg();
         if ($this->client->getLastCode() != 201) {
             throw new \RuntimeException("Account not initialized, probably due to rate limiting. Whole response: " . $response);
         }
         $this->postNewReg();
         $this->log('New account certificate registered');
     } else {
         $this->log('Account already registered. Continuing.');
     }
 }
/**
 * store the default index-file in a given destination folder
 * 
 * @param string  $loginname   customers loginname
 * @param string  $destination path where to create the file
 * @param object  $logger      FroxlorLogger object
 * @param boolean $force       force creation whatever the settings say (needed for task #2, create new user)
 * 
 * @return null
 */
function storeDefaultIndex($loginname = null, $destination = null, $logger = null, $force = false)
{
    if ($force || (int) Settings::Get('system.store_index_file_subs') == 1) {
        $result_stmt = Database::prepare("\n\t\t\tSELECT `t`.`value`, `c`.`email` AS `customer_email`, `a`.`email` AS `admin_email`, `c`.`loginname` AS `customer_login`, `a`.`loginname` AS `admin_login`\n\t\t\tFROM `" . TABLE_PANEL_CUSTOMERS . "` AS `c` INNER JOIN `" . TABLE_PANEL_ADMINS . "` AS `a`\n\t\t\tON `c`.`adminid` = `a`.`adminid`\n\t\t\tINNER JOIN `" . TABLE_PANEL_TEMPLATES . "` AS `t`\n\t\t\tON `a`.`adminid` = `t`.`adminid`\n\t\t\tWHERE `varname` = 'index_html' AND `c`.`loginname` = :loginname");
        Database::pexecute($result_stmt, array('loginname' => $loginname));
        if (Database::num_rows() > 0) {
            $template = $result_stmt->fetch(PDO::FETCH_ASSOC);
            $replace_arr = array('SERVERNAME' => Settings::Get('system.hostname'), 'CUSTOMER' => $template['customer_login'], 'ADMIN' => $template['admin_login'], 'CUSTOMER_EMAIL' => $template['customer_email'], 'ADMIN_EMAIL' => $template['admin_email']);
            $htmlcontent = replace_variables($template['value'], $replace_arr);
            $indexhtmlpath = makeCorrectFile($destination . '/index.' . Settings::Get('system.index_file_extension'));
            $index_html_handler = fopen($indexhtmlpath, 'w');
            fwrite($index_html_handler, $htmlcontent);
            fclose($index_html_handler);
            if ($logger !== null) {
                $logger->logAction(CRON_ACTION, LOG_NOTICE, 'Creating \'index.' . Settings::Get('system.index_file_extension') . '\' for Customer \'' . $template['customer_login'] . '\' based on template in directory ' . escapeshellarg($indexhtmlpath));
            }
        } else {
            $destination = makeCorrectDir($destination);
            if ($logger !== null) {
                $logger->logAction(CRON_ACTION, LOG_NOTICE, 'Running: cp -a ' . FROXLOR_INSTALL_DIR . '/templates/misc/standardcustomer/* ' . escapeshellarg($destination));
            }
            safe_exec('cp -a ' . FROXLOR_INSTALL_DIR . '/templates/misc/standardcustomer/* ' . escapeshellarg($destination));
        }
    }
    return;
}
/**
 * Whenever the webserver- / FCGID- or FPM-user gets updated
 * we need to update ftp_groups accordingly
 */
function storeSettingWebserverFcgidFpmUser($fieldname, $fielddata, $newfieldvalue)
{
    if (is_array($fielddata) && isset($fielddata['settinggroup']) && isset($fielddata['varname'])) {
        $update_user = null;
        // webserver
        if ($fielddata['settinggroup'] == 'system' && $fielddata['varname'] == 'httpuser') {
            $update_user = Settings::Get('system.httpuser');
        }
        // fcgid
        if ($fielddata['settinggroup'] == 'system' && $fielddata['varname'] == 'mod_fcgid_httpuser') {
            $update_user = Settings::Get('system.mod_fcgid_httpuser');
        }
        // webserver
        if ($fielddata['settinggroup'] == 'phpfpm' && $fielddata['varname'] == 'vhost_httpuser') {
            $update_user = Settings::Get('phpfpm.vhost_httpuser');
        }
        $returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
        if ($returnvalue !== false) {
            /**
             * only update if anything changed
             */
            if ($update_user != null && $newfieldvalue != $update_user) {
                $upd_stmt = Database::prepare("UPDATE `" . TABLE_FTP_GROUPS . "` SET `members` = REPLACE(`members`, :olduser, :newuser)");
                Database::pexecute($upd_stmt, array('olduser' => $update_user, 'newuser' => $newfieldvalue));
            }
        }
    }
    return $returnvalue;
}
/**
 * This file is part of the Froxlor project.
 * Copyright (c) 2003-2009 the SysCP Team (see authors).
 * Copyright (c) 2010 the Froxlor Team (see authors).
 *
 * For the full copyright and license information, please view the COPYING
 * file that was distributed with this source code. You can also view the
 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
 *
 * @copyright  (c) the authors
 * @author     Florian Lippert <*****@*****.**> (2003-2009)
 * @author     Froxlor team <*****@*****.**> (2010-)
 * @license    GPLv2 http://files.froxlor.org/misc/COPYING.txt
 * @package    Functions
 *
 */
function storeSettingDefaultIp($fieldname, $fielddata, $newfieldvalue)
{
    $defaultips_old = Settings::Get('system.defaultip');
    $returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
    if ($returnvalue !== false && is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] == 'system' && isset($fielddata['varname']) && $fielddata['varname'] == 'defaultip') {
        $customerstddomains_result_stmt = Database::prepare("\n\t\t\tSELECT `standardsubdomain` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `standardsubdomain` <> '0'\n\t\t");
        Database::pexecute($customerstddomains_result_stmt);
        $ids = array();
        while ($customerstddomains_row = $customerstddomains_result_stmt->fetch(PDO::FETCH_ASSOC)) {
            $ids[] = (int) $customerstddomains_row['standardsubdomain'];
        }
        if (count($ids) > 0) {
            $defaultips_new = explode(',', $newfieldvalue);
            // Delete the existing mappings linking to default IPs
            $del_stmt = Database::prepare("\n\t\t\t\t\tDELETE FROM `" . TABLE_DOMAINTOIP . "`\n\t\t\t\t\tWHERE `id_domain` IN (" . implode(', ', $ids) . ")\n\t\t\t\t\tAND `id_ipandports` IN (" . $defaultips_old . ", " . $newfieldvalue . ")\n\t\t\t");
            Database::pexecute($del_stmt);
            // Insert the new mappings
            $ins_stmt = Database::prepare("\n\t\t\t\tINSERT INTO `" . TABLE_DOMAINTOIP . "`\n\t\t\t\tSET `id_domain` = :domainid, `id_ipandports` = :ipandportid\n\t\t\t");
            foreach ($ids as $id) {
                foreach ($defaultips_new as $defaultip_new) {
                    Database::pexecute($ins_stmt, array('domainid' => $id, 'ipandportid' => $defaultip_new));
                }
            }
        }
    }
    return $returnvalue;
}
 /**
  * constructor
  * @param string logFile
  * @param int startTime
  * @param string logFileExim
  */
 public function __construct($startTime = 0)
 {
     $this->startTime = $startTime;
     // Get all domains from Database
     $stmt = Database::prepare("SELECT domain FROM `" . TABLE_PANEL_DOMAINS . "`");
     Database::pexecute($stmt, array());
     while ($domain_row = $stmt->fetch(PDO::FETCH_ASSOC)) {
         $this->myDomains[] = $domain_row["domain"];
     }
     // Parse MTA traffic
     if (Settings::Get("system.mtaserver") == "postfix") {
         $this->_parsePostfixLog(Settings::Get("system.mtalog"));
         $this->_parsePostfixLog(Settings::Get("system.mtalog") . ".1");
     } elseif (Settings::Get("system.mtaserver") == "exim4") {
         $this->_parseExim4Log(Settings::Get("system.mtalog"));
     }
     // Parse MDA traffic
     if (Settings::Get("system.mdaserver") == "dovecot") {
         $this->_parseDovecotLog(Settings::Get("system.mdalog"));
         $this->_parsePostfixLog(Settings::Get("system.mdalog") . ".1");
     } elseif (Settings::Get("system.mdaserver") == "courier") {
         $this->_parseCourierLog(Settings::Get("system.mdalog"));
         $this->_parsePostfixLog(Settings::Get("system.mdalog") . ".1");
     }
 }
/**
 * This file is part of the Froxlor project.
 * Copyright (c) 2003-2009 the SysCP Team (see authors).
 * Copyright (c) 2010 the Froxlor Team (see authors).
 *
 * For the full copyright and license information, please view the COPYING
 * file that was distributed with this source code. You can also view the
 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
 *
 * @copyright  (c) the authors
 * @author     Florian Lippert <*****@*****.**> (2003-2009)
 * @author     Froxlor team <*****@*****.**> (2010-)
 * @license    GPLv2 http://files.froxlor.org/misc/COPYING.txt
 * @package    Functions
 *
 */
function getIpPortCombinations($ssl = false)
{
    global $userinfo;
    $additional_conditions_params = array();
    $additional_conditions_array = array();
    if ($userinfo['ip'] != '-1') {
        $admin_ip_stmt = Database::prepare("\n\t\t\tSELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id` = :ipid\n\t\t");
        $admin_ip = Database::pexecute_first($admin_ip_stmt, array('ipid' => $userinfo['ip']));
        $additional_conditions_array[] = "`ip` = :adminip";
        $additional_conditions_params['adminip'] = $admin_ip['ip'];
        $admin_ip = null;
    }
    if ($ssl !== null) {
        $additional_conditions_array[] = "`ssl` = :ssl";
        $additional_conditions_params['ssl'] = $ssl === true ? '1' : '0';
    }
    $additional_conditions = '';
    if (count($additional_conditions_array) > 0) {
        $additional_conditions = " WHERE " . implode(" AND ", $additional_conditions_array) . " ";
    }
    $result_stmt = Database::prepare("\n\t\tSELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` " . $additional_conditions . " ORDER BY `ip` ASC, `port` ASC\n\t");
    Database::pexecute($result_stmt, $additional_conditions_params);
    $system_ipaddress_array = array();
    while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
        if (filter_var($row['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
            $row['ip'] = '[' . $row['ip'] . ']';
        }
        $system_ipaddress_array[$row['id']] = $row['ip'] . ':' . $row['port'];
    }
    return $system_ipaddress_array;
}
/**
 * Function validatePasswordLogin
 *
 * compare user password-hash with given user-password
 * and check if they are the same
 * additionally it updates the hash if the system settings changed
 * or if the very old md5() sum is used
 *
 * @param array $userinfo user-data from table
 * @param string $password the password to validate
 * @param string $table either panel_customers or panel_admins
 * @param string $uid user-id-field in $table
 *
 * @return boolean
 */
function validatePasswordLogin($userinfo = null, $password = null, $table = 'panel_customers', $uid = 'customerid')
{
    $systype = 3;
    // SHA256
    if (Settings::Get('system.passwordcryptfunc') !== null) {
        $systype = (int) Settings::Get('system.passwordcryptfunc');
    }
    $pwd_hash = $userinfo['password'];
    $update_hash = false;
    // check for good'ole md5
    if (strlen($pwd_hash) == 32 && ctype_xdigit($pwd_hash)) {
        $pwd_check = md5($password);
        $update_hash = true;
    } else {
        // cut out the salt from the hash
        $pwd_salt = str_replace(substr(strrchr($pwd_hash, "\$"), 1), "", $pwd_hash);
        // create same hash to compare
        $pwd_check = crypt($password, $pwd_salt);
        // check whether the hash needs to be updated
        $hash_type_chk = substr($pwd_hash, 0, 3);
        if ($systype == 1 && $hash_type_chk != '$1$' || $systype == 2 && $hash_type_chk != '$2$' || $systype == 3 && $hash_type_chk != '$5$' || $systype == 4 && $hash_type_chk != '$6$') {
            $update_hash = true;
        }
    }
    if ($pwd_hash == $pwd_check) {
        // check for update of hash
        if ($update_hash) {
            $upd_stmt = Database::prepare("\n\t\t\t\tUPDATE " . $table . " SET `password` = :newpasswd WHERE `" . $uid . "` = :uid\n\t\t\t");
            $params = array('newpasswd' => makeCryptPassword($password), 'uid' => $userinfo[$uid]);
            Database::pexecute($upd_stmt, $params);
        }
        return true;
    }
    return false;
}
Example #8
0
 public function initAccount($certrow, $isFroxlorVhost = false)
 {
     // Let's see if we have the private accountkey
     $this->accountKey = $certrow['leprivatekey'];
     if (!$this->accountKey || $this->accountKey == 'unset' || Settings::Get('system.letsencryptca') != 'production') {
         // generate and save new private key for account
         // ---------------------------------------------
         $this->log('Starting new account registration');
         $keys = $this->generateKey();
         // Only store the accountkey in production, in staging always generate a new key
         if (Settings::Get('system.letsencryptca') == 'production') {
             if ($isFroxlorVhost) {
                 Settings::Set('system.lepublickey', $keys['public']);
                 Settings::Set('system.leprivatekey', $keys['private']);
             } else {
                 $upd_stmt = Database::prepare("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `lepublickey` = :public, `leprivatekey` = :private " . "WHERE `customerid` = :customerid;");
                 Database::pexecute($upd_stmt, array('public' => $keys['public'], 'private' => $keys['private'], 'customerid' => $certrow['customerid']));
             }
         }
         $this->accountKey = $keys['private'];
         $response = $this->postNewReg();
         if ($this->client->getLastCode() != 201) {
             throw new \RuntimeException("Account not initialized, probably due to rate limiting. Whole response: " . json_encode($response));
         }
         $this->license = $this->client->getAgreementURL();
         // Terms of Servce are optional according to ACME specs; if no ToS are presented, no need to update registration
         if (!empty($this->license)) {
             $this->postRegAgreement(parse_url($this->client->getLastLocation(), PHP_URL_PATH));
         }
         $this->log('New account certificate registered');
     } else {
         $this->log('Account already registered. Continuing.');
     }
 }
function toggleCronStatus($module = null, $isactive = 0)
{
    if ($isactive != 1) {
        $isactive = 0;
    }
    $upd_stmt = Database::prepare("\n\t\tUPDATE `" . TABLE_PANEL_CRONRUNS . "` SET `isactive` = :active WHERE `module` = :module");
    Database::pexecute($upd_stmt, array('active' => $isactive, 'module' => $module));
}
/**
 * This file is part of the Froxlor project.
 * Copyright (c) 2010 the Froxlor Team (see authors).
 *
 * For the full copyright and license information, please view the COPYING
 * file that was distributed with this source code. You can also view the
 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
 *
 * @copyright  (c) the authors
 * @author     Daniel Reichelt <*****@*****.**> (2016-)
 * @license    GPLv2 http://files.froxlor.org/misc/COPYING.txt
 * @package    Functions
 *
 */
function triggerLetsEncryptCSRForAliasDestinationDomain($aliasDestinationDomainID, $log)
{
    if (isset($aliasDestinationDomainID) && $aliasDestinationDomainID > 0) {
        $log->logAction(ADM_ACTION, LOG_INFO, "LetsEncrypt CSR triggered for domain ID " . $aliasDestinationDomainID);
        $upd_stmt = Database::prepare("UPDATE\n\t\t\t\t\t`" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "`\n\t\t\t\tSET\n\t\t\t\t\t`expirationdate` = null\n\t\t\t\tWHERE\n\t\t\t\t\tdomainid = :domainid\n\t\t\t");
        Database::pexecute($upd_stmt, array('domainid' => $aliasDestinationDomainID));
    }
}
/**
 * check whether a subof-domain exists
 * #329
 * 
 *  @param int $id subof-domain-id
 *  
 *  @return boolean
 */
function domainMainToSubExists($id = 0)
{
    $result_stmt = Database::prepare("\n\t\tSELECT `id` FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `id` = :id");
    Database::pexecute($result_stmt, array('id' => $id));
    $result = $result_stmt->fetch(PDO::FETCH_ASSOC);
    if (isset($result['id']) && $result['id'] > 0) {
        return true;
    }
    return false;
}
/**
 * Function updateToVersion
 *
 * updates the panel.version field
 * to the given value (no checks here!)
 *
 * @param string $new_version new-version
 *
 * @return bool true on success, else false
 */
function updateToVersion($new_version = null)
{
    if ($new_version !== null && $new_version != '') {
        $upd_stmt = Database::prepare("\n\t\t\t\tUPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = :newversion\n\t\t\t\tWHERE `settinggroup` = 'panel' AND `varname` = 'version'");
        Database::pexecute($upd_stmt, array('newversion' => $new_version));
        Settings::Set('panel.version', $new_version);
        return true;
    }
    return false;
}
/**
 * Check whether a given domain has an ssl-ip/port assigned
 *
 * @param int $domainid
 *
 * @return boolean
 */
function domainHasSslIpPort($domainid = 0)
{
    $result_stmt = Database::prepare("\n\t\t\tSELECT `dt`.* FROM `" . TABLE_DOMAINTOIP . "` `dt`, `" . TABLE_PANEL_IPSANDPORTS . "` `iap`\n\t\t\tWHERE `dt`.`id_ipandports` = `iap`.`id` AND `iap`.`ssl` = '1' AND `dt`.`id_domain` = :domainid;");
    Database::pexecute($result_stmt, array('domainid' => $domainid));
    $result = $result_stmt->fetch(PDO::FETCH_ASSOC);
    if (is_array($result) && isset($result['id_ipandports'])) {
        return true;
    }
    return false;
}
/**
 * Function checkDomainIPConfigured
 *
 * Checks whether a domain has at least one ipandport which is actually
 * configured on any interface of the current host
 *
 * @param int $domainid domain id
 *
 * @return true if ip is configured, false otherwise
 */
function checkDomainIPConfigured($domainid)
{
    $result_stmt = Database::prepare("SELECT `ipp`.`ip` FROM `" . TABLE_DOMAINTOIP . "` `dip`\n\t\t\tLEFT JOIN `" . TABLE_PANEL_IPSANDPORTS . "` `ipp` ON (`dip`.`id_ipandports` = `ipp`.`id`)\n\t\t\t   WHERE `dip`.`id_domain` = :domainid;");
    Database::pexecute($result_stmt, array('domainid' => (int) $domainid));
    while ($result = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
        if (checkIPConfigured($result['ip'])) {
            return true;
        }
    }
    return false;
}
/**
 * Function customerHasPerlEnabled
 *
 * returns true or false whether perl is
 * enabled for the given customer
 *
 * @param int customer-id
 *
 * @return boolean
 */
function customerHasPerlEnabled($cid = 0)
{
    if ($cid > 0) {
        $result_stmt = Database::prepare("\n\t\t\t\tSELECT `perlenabled` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `customerid` = :cid");
        Database::pexecute($result_stmt, array('cid' => $cid));
        $result = $result_stmt->fetch(PDO::FETCH_ASSOC);
        if (is_array($result) && isset($result['perlenabled'])) {
            return $result['perlenabled'] == '1' ? true : false;
        }
    }
    return false;
}
/**
 * check whether an email account is to be deleted
 * reference: #1519
 *
 * @return bool true if the domain is to be deleted, false otherwise
 *        
 */
function checkMailAccDeletionState($email_addr = null)
{
    // example data of task 7: a:2:{s:9:"loginname";s:4:"webX";s:5:"email";s:20:"*****@*****.**";}
    // check for task
    $result_tasks_stmt = Database::prepare("\n\t\tSELECT * FROM `" . TABLE_PANEL_TASKS . "` WHERE `type` = '7' AND `data` LIKE :emailaddr\n\t");
    Database::pexecute($result_tasks_stmt, array('emailaddr' => "%" . $email_addr . "%"));
    $num_results = Database::num_rows();
    // is there a task for deleting this email account?
    if ($num_results > 0) {
        return true;
    }
    return false;
}
/**
 * This file is part of the Froxlor project.
 * Copyright (c) 2003-2009 the SysCP Team (see authors).
 * Copyright (c) 2010 the Froxlor Team (see authors).
 *
 * For the full copyright and license information, please view the COPYING
 * file that was distributed with this source code. You can also view the
 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
 *
 * @copyright  (c) the authors
 * @author     Froxlor team <*****@*****.**> (2010-)
 * @license    GPLv2 http://files.froxlor.org/misc/COPYING.txt
 * @package    Functions
 *
 */
function storeSettingResetCatchall($fieldname, $fielddata, $newfieldvalue)
{
    $returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
    if ($returnvalue !== false && is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] == 'catchall' && isset($fielddata['varname']) && $fielddata['varname'] == 'catchall_enabled' && $newfieldvalue == '0') {
        $result_stmt = Database::query("\n\t\t\tSELECT `id`, `email`, `email_full`, `iscatchall`  FROM `" . TABLE_MAIL_VIRTUAL . "`\n\t\t\tWHERE `iscatchall` = '1'\n\t\t");
        if (Database::num_rows() > 0) {
            $upd_stmt = Database::prepare("\n\t\t\t\tUPDATE `" . TABLE_MAIL_VIRTUAL . "` SET `email` = :email, `iscatchall` = '0' WHERE `id` = :id\n\t\t\t");
            while ($result_row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
                Database::pexecute($upd_stmt, array('email' => $result_row['email_full'], 'id' => $result_row['id']));
            }
        }
    }
    return $returnvalue;
}
Example #18
0
/**
 * Inserts a task into the PANEL_TASKS-Table
 *
 * @param int Type of task
 * @param string Parameter 1
 * @param string Parameter 2
 * @param string Parameter 3
 * @author Florian Lippert <*****@*****.**>
 * @author Froxlor team <*****@*****.**>
 */
function inserttask($type, $param1 = '', $param2 = '', $param3 = '', $param4 = '')
{
    // prepare the insert-statement
    $ins_stmt = Database::prepare("\n\t\tINSERT INTO `" . TABLE_PANEL_TASKS . "` SET `type` = :type, `data` = :data\n\t");
    if ($type == '1' || $type == '3' || $type == '4' || $type == '5' || $type == '10' || $type == '99') {
        // 4 = bind -> if bind disabled -> no task
        if ($type == '4' && Settings::Get('system.bind_enable') == '0') {
            return;
        }
        // 10 = quota -> if quota disabled -> no task
        if ($type == '10' && Settings::Get('system.diskquota_enabled') == '0') {
            return;
        }
        // delete previously inserted tasks if they are the same as we only need ONE
        $del_stmt = Database::prepare("\n\t\t\tDELETE FROM `" . TABLE_PANEL_TASKS . "` WHERE `type` = :type\n\t\t");
        Database::pexecute($del_stmt, array('type' => $type));
        // insert the new task
        Database::pexecute($ins_stmt, array('type' => $type, 'data' => ''));
    } elseif ($type == '2' && $param1 != '' && $param2 != '' && $param3 != '' && ($param4 == 0 || $param4 == 1)) {
        $data = array();
        $data['loginname'] = $param1;
        $data['uid'] = $param2;
        $data['gid'] = $param3;
        $data['store_defaultindex'] = $param4;
        $data = serialize($data);
        Database::pexecute($ins_stmt, array('type' => '2', 'data' => $data));
    } elseif ($type == '6' && $param1 != '') {
        $data = array();
        $data['loginname'] = $param1;
        $data = serialize($data);
        Database::pexecute($ins_stmt, array('type' => '6', 'data' => $data));
    } elseif ($type == '7' && $param1 != '' && $param2 != '') {
        $data = array();
        $data['loginname'] = $param1;
        $data['email'] = $param2;
        $data = serialize($data);
        Database::pexecute($ins_stmt, array('type' => '7', 'data' => $data));
    } elseif ($type == '8' && $param1 != '' && $param2 != '') {
        $data = array();
        $data['loginname'] = $param1;
        $data['homedir'] = $param2;
        $data = serialize($data);
        Database::pexecute($ins_stmt, array('type' => '8', 'data' => $data));
    } elseif ($type == '20' && is_array($param1)) {
        $data = serialize($param1);
        Database::pexecute($ins_stmt, array('type' => '20', 'data' => $data));
    }
}
/**
 * This file is part of the Froxlor project.
 * Copyright (c) 2003-2009 the SysCP Team (see authors).
 * Copyright (c) 2010 the Froxlor Team (see authors).
 *
 * For the full copyright and license information, please view the COPYING
 * file that was distributed with this source code. You can also view the
 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
 *
 * @copyright  (c) the authors
 * @author     Florian Lippert <*****@*****.**> (2003-2009)
 * @author     Froxlor team <*****@*****.**> (2010-)
 * @license    GPLv2 http://files.froxlor.org/misc/COPYING.txt
 * @package    Functions
 *
 */
function storeSettingDefaultIp($fieldname, $fielddata, $newfieldvalue)
{
    $returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
    if ($returnvalue !== false && is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] == 'system' && isset($fielddata['varname']) && $fielddata['varname'] == 'defaultip') {
        $customerstddomains_result_stmt = Database::prepare("\n\t\t\tSELECT `standardsubdomain` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `standardsubdomain` <> '0'\n\t\t");
        Database::pexecute($customerstddomains_result_stmt);
        $ids = array();
        while ($customerstddomains_row = $customerstddomains_result_stmt->fetch(PDO::FETCH_ASSOC)) {
            $ids[] = (int) $customerstddomains_row['standardsubdomain'];
        }
        if (count($ids) > 0) {
            $upd_stmt = Database::prepare("\n\t\t\t\tUPDATE `" . TABLE_DOMAINTOIP . "` SET\n\t\t\t\t`id_ipandports` = :newval\n\t\t\t\tWHERE `id_domain` IN ('" . implode(', ', $ids) . "')\n\t\t\t\tAND `id_ipandports` = :defaultip\n\t\t\t");
            Database::pexecute($upd_stmt, array('newval' => $newfieldvalue, 'defaultip' => Settings::Get('system.defaultip')));
        }
    }
    return $returnvalue;
}
Example #20
0
 public function initAccount($certrow)
 {
     // Let's see if we have the private accountkey
     $this->accountKey = $certrow['leprivatekey'];
     if (!$this->accountKey || $this->accountKey == 'unset') {
         // generate and save new private key for account
         // ---------------------------------------------
         $this->log('Starting new account registration');
         $keys = $this->generateKey();
         $upd_stmt = Database::prepare("\n                UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `lepublickey` = :public, `leprivatekey` = :private WHERE `customerid` = :customerid;\n            ");
         Database::pexecute($upd_stmt, array('public' => $keys['public'], 'private' => $keys['private'], 'customerid' => $certrow['customerid']));
         $this->accountKey = $keys['private'];
         $this->postNewReg();
         $this->log('New account certificate registered');
     } else {
         $this->log('Account already registered. Continuing.');
     }
 }
/**
 * updates the setting for the default panel-theme
 * and also the user themes (customers and admins) if
 * the changing of themes is disallowed for them
 *
 * @param string $fieldname
 * @param array $fielddata
 * @param mixed $newfieldvalue
 *
 * @return boolean|array
 */
function storeSettingDefaultTheme($fieldname, $fielddata, $newfieldvalue)
{
    // first save the setting itself
    $returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
    if ($returnvalue !== false && is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] == 'panel' && isset($fielddata['varname']) && $fielddata['varname'] == 'default_theme') {
        // now, if changing themes is disabled we recursivly set
        // the new theme (customers and admin, depending on settings)
        if (Settings::Get('panel.allow_theme_change_customer') == '0') {
            $upd_stmt = Database::prepare("\n\t\t\t\tUPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `theme` = :theme\n\t\t\t");
            Database::pexecute($upd_stmt, array('theme' => $newfieldvalue));
        }
        if (Settings::Get('panel.allow_theme_change_admin') == '0') {
            $upd_stmt = Database::prepare("\n\t\t\t\tUPDATE `" . TABLE_PANEL_ADMINS . "` SET `theme` = :theme\n\t\t\t");
            Database::pexecute($upd_stmt, array('theme' => $newfieldvalue));
        }
    }
    return $returnvalue;
}
/**
 * This file is part of the Froxlor project.
 * Copyright (c) 2003-2009 the SysCP Team (see authors).
 * Copyright (c) 2010 the Froxlor Team (see authors).
 *
 * For the full copyright and license information, please view the COPYING
 * file that was distributed with this source code. You can also view the
 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
 *
 * @copyright  (c) the authors
 * @author     Florian Lippert <*****@*****.**> (2003-2009)
 * @author     Froxlor team <*****@*****.**> (2010-)
 * @license    GPLv2 http://files.froxlor.org/misc/COPYING.txt
 * @package    Functions
 *
 */
function storeSettingHostname($fieldname, $fielddata, $newfieldvalue)
{
    global $idna_convert;
    $returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
    if ($returnvalue !== false && is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] == 'system' && isset($fielddata['varname']) && $fielddata['varname'] == 'hostname') {
        $newfieldvalue = $idna_convert->encode($newfieldvalue);
        $customerstddomains_result_stmt = Database::prepare("\n\t\t\tSELECT `standardsubdomain` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `standardsubdomain` <> '0'\n\t\t");
        Database::pexecute($customerstddomains_result_stmt);
        $ids = array();
        while ($customerstddomains_row = $customerstddomains_result_stmt->fetch(PDO::FETCH_ASSOC)) {
            $ids[] = (int) $customerstddomains_row['standardsubdomain'];
        }
        if (count($ids) > 0) {
            $upd_stmt = Database::prepare("\n\t\t\t\tUPDATE `" . TABLE_PANEL_DOMAINS . "` SET\n\t\t\t\t`domain` = REPLACE(`domain`, :host, :newval)\n\t\t\t\tWHERE `id` IN ('" . implode(', ', $ids) . "')\n\t\t\t");
            Database::pexecute($upd_stmt, array('host' => Settings::Get('system.hostname'), 'newval' => $newfieldvalue));
        }
    }
    return $returnvalue;
}
/**
 * This file is part of the Froxlor project.
 * Copyright (c) 2003-2009 the SysCP Team (see authors).
 * Copyright (c) 2010 the Froxlor Team (see authors).
 *
 * For the full copyright and license information, please view the COPYING
 * file that was distributed with this source code. You can also view the
 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
 *
 * @copyright  (c) the authors
 * @author     Florian Lippert <*****@*****.**> (2003-2009)
 * @author     Froxlor team <*****@*****.**> (2010-)
 * @license    GPLv2 http://files.froxlor.org/misc/COPYING.txt
 * @package    Functions
 *
 */
function correctMysqlUsers($mysql_access_host_array)
{
    global $log;
    // get sql-root access data
    Database::needRoot(true);
    Database::needSqlData();
    $sql_root = Database::getSqlData();
    Database::needRoot(false);
    $dbservers_stmt = Database::query("SELECT DISTINCT `dbserver` FROM `" . TABLE_PANEL_DATABASES . "`");
    $mysql_servers = '';
    while ($dbserver = $dbservers_stmt->fetch(PDO::FETCH_ASSOC)) {
        Database::needRoot(true, $dbserver['dbserver']);
        Database::needSqlData();
        $sql_root = Database::getSqlData();
        $dbm = new DbManager($log);
        $users = $dbm->getManager()->getAllSqlUsers(false);
        $databases = array($sql_root['db']);
        $databases_result_stmt = Database::prepare("\n\t\t\tSELECT * FROM `" . TABLE_PANEL_DATABASES . "`\n\t\t\tWHERE `dbserver` = :mysqlserver\n\t\t");
        Database::pexecute($databases_result_stmt, array('mysqlserver' => $dbserver['dbserver']));
        while ($databases_row = $databases_result_stmt->fetch(PDO::FETCH_ASSOC)) {
            $databases[] = $databases_row['databasename'];
        }
        foreach ($databases as $username) {
            if (isset($users[$username]) && is_array($users[$username]) && isset($users[$username]['hosts']) && is_array($users[$username]['hosts'])) {
                $password = $users[$username]['password'];
                foreach ($mysql_access_host_array as $mysql_access_host) {
                    $mysql_access_host = trim($mysql_access_host);
                    if (!in_array($mysql_access_host, $users[$username]['hosts'])) {
                        $dbm->getManager()->grantPrivilegesTo($username, $password, $mysql_access_host, true);
                    }
                }
                foreach ($users[$username]['hosts'] as $mysql_access_host) {
                    if (!in_array($mysql_access_host, $mysql_access_host_array)) {
                        $dbm->getManager()->deleteUser($username, $mysql_access_host);
                    }
                }
            }
        }
        $dbm->getManager()->flushPrivileges();
        Database::needRoot(false);
    }
}
/**
 * Function to move a given customer to a given admin/reseller
 * and update all its references accordingly
 *
 * @param int $id customer-id
 * @param int $adminid target-admin-id
 *
 * @return true on sucess, error-message on failure
 */
function moveCustomerToAdmin($id = 0, $adminid = 0)
{
    if ($id <= 0 || $adminid <= 0) {
        return "no valid id's given";
    }
    // get current admin-id
    $cAdmin_stmt = Database::prepare("\n\t\tSELECT `adminid` FROM `" . TABLE_PANEL_CUSTOMERS . "`\n\t\tWHERE `customerid` = :cid\n\t");
    $cAdmin = Database::pexecute_first($cAdmin_stmt, array('cid' => $id));
    // Update customer entry
    $updCustomer_stmt = Database::prepare("\n\t\tUPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `adminid` = :adminid WHERE `customerid` = :cid\n\t");
    Database::pexecute($updCustomer_stmt, array('adminid' => $cAdmin['adminid'], 'cid' => $id));
    // Update customer-domains
    $updDomains_stmt = Database::prepare("\n\t\tUPDATE `" . TABLE_PANEL_DOMAINS . "` SET `adminid` = :adminid WHERE `customerid` = :cid\n\t");
    Database::pexecute($updDomains_stmt, array('adminid' => $cAdmin['adminid'], 'cid' => $id));
    // Update customer-tickets
    $updTickets_stmt = Database::prepare("\n\t\tUPDATE `" . TABLE_PANEL_TICKETS . "` SET `adminid` = :adminid WHERE `customerid` = :cid\n\t");
    Database::pexecute($updTickets_stmt, array('adminid' => $cAdmin['adminid'], 'cid' => $id));
    // now, recalculate the resource-usage for the old and the new admin
    updateCounters(false);
    return true;
}
Example #25
0
 /**
  * logs a given text to all enabled logger-facilities
  *
  * @param int $action
  * @param int $type
  * @param string $text
  */
 public function logAction($action = USR_ACTION, $type = LOG_NOTICE, $text = null)
 {
     if (parent::isEnabled()) {
         if (parent::getSeverity() <= 1 && $type == LOG_NOTICE) {
             return;
         }
         if (!isset($this->userinfo['loginname']) || $this->userinfo['loginname'] == '') {
             $name = 'unknown';
         } else {
             $name = $this->userinfo['loginname'];
         }
         $now = time();
         $stmt = Database::prepare("\n\t\t\t\t\tINSERT INTO `panel_syslog` SET\n\t\t\t\t\t`type` = :type,\n\t\t\t\t\t`date` = :now,\n\t\t\t\t\t`action` = :action,\n\t\t\t\t\t`user` = :user,\n\t\t\t\t\t`text` = :text");
         $ins_data = array('type' => $type, 'now' => $now, 'action' => $action, 'user' => $name);
         if ($text != null && $text != '') {
             $ins_data['text'] = $text;
             Database::pexecute($stmt, $ins_data);
         } else {
             $ins_data['text'] = 'No text given!!! Check scripts!';
             Database::pexecute($stmt, $ins_data);
         }
     }
 }
Example #26
0
            try {
                $bulk = new DomainBulkAction($file_name, $customerid);
                $result = $bulk->doImport($separator, $offset);
            } catch (Exception $e) {
                standard_error('domain_import_error', $e->getMessage());
            }
            // @FIXME find a way to display $result['notice'] here somehow,
            //        as it might be important if you've reached your maximum allocation of domains
            // update customer/admin counters
            updateCounters(false);
            $result_str = $result['imported'] . ' / ' . $result['all'];
            standard_success('domain_import_successfully', $result_str, array('filename' => $filename, 'action' => '', 'page' => 'domains'));
        } else {
            $customers = makeoption($lng['panel']['please_choose'], 0, 0, true);
            $result_customers_stmt = Database::prepare("\n\t\t\t\tSELECT `customerid`, `loginname`, `name`, `firstname`, `company`\n\t\t\t\tFROM `" . TABLE_PANEL_CUSTOMERS . "` " . ($userinfo['customers_see_all'] ? '' : " WHERE `adminid` = '" . (int) $userinfo['adminid'] . "' ") . " ORDER BY `name` ASC");
            $params = array();
            if ($userinfo['customers_see_all'] == '0') {
                $params['adminid'] = $userinfo['adminid'];
            }
            Database::pexecute($result_customers_stmt, $params);
            while ($row_customer = $result_customers_stmt->fetch(PDO::FETCH_ASSOC)) {
                $customers .= makeoption(getCorrectFullUserDetails($row_customer) . ' (' . $row_customer['loginname'] . ')', $row_customer['customerid']);
            }
            $domain_import_data = (include_once dirname(__FILE__) . '/lib/formfields/admin/domains/formfield.domains_import.php');
            $domain_import_form = htmlform::genHTMLForm($domain_import_data);
            $title = $domain_import_data['domain_import']['title'];
            $image = $domain_import_data['domain_import']['image'];
            eval("echo \"" . getTemplate("domains/domains_import") . "\";");
        }
    }
}
 /**
  * check whether the local froxlor user is in
  * the customers groups when fcgid / php-fpm and
  * fcgid/fpm in froxlor vhost is used
  *
  * @param bool $fix fix member/groups
  *
  * @return boolean
  */
 public function FroxlorLocalGroupMemberForFcgidPhpFpm($fix = false)
 {
     if (Settings::Get('system.mod_fcgid') == 0 && Settings::Get('phpfpm.enabled') == 0) {
         return true;
     }
     if (Settings::get('system.mod_fcgid') == 1) {
         if (Settings::get('system.mod_fcgid_ownvhost') == 0) {
             return true;
         } else {
             $localuser = Settings::Get('system.mod_fcgid_httpuser');
         }
     }
     if (Settings::get('phpfpm.enabled') == 1) {
         if (Settings::get('phpfpm.enabled_ownvhost') == 0) {
             return true;
         } else {
             $localuser = Settings::Get('phpfpm.vhost_httpuser');
         }
     }
     // get all customers that don't have the webserver-user in their group
     $cwg_stmt = Database::prepare("\n\t       SELECT `id` FROM `" . TABLE_FTP_GROUPS . "` WHERE NOT FIND_IN_SET(:localuser, `members`)\n\t    ");
     Database::pexecute($cwg_stmt, array('localuser' => $localuser));
     if ($cwg_stmt->rowCount() > 0) {
         $this->_log->logAction(ADM_ACTION, LOG_NOTICE, "Customers are missing the local froxlor-user as group-member, integrity-check can fix that");
         if ($fix) {
             // prepare update statement
             $upd_stmt = Database::prepare("\n\t                UPDATE `" . TABLE_FTP_GROUPS . "` SET `members` = CONCAT(`members`, :additionaluser)\n\t                WHERE `id` = :id\n\t            ");
             $upd_data = array('additionaluser' => "," . $localuser);
             while ($cwg_row = $cwg_stmt->fetch()) {
                 $upd_data['id'] = $cwg_row['id'];
                 Database::pexecute($upd_stmt, $upd_data);
             }
             $this->_log->logAction(ADM_ACTION, LOG_NOTICE, "Customers were missing the local froxlor-user as group-member, integrity-check fixed that");
         } else {
             return false;
         }
     }
     if ($fix) {
         return $this->FroxlorLocalGroupMemberForFcgidPhpFpm();
     }
     return true;
 }
 /**
  * We compose the virtualhost entry for one domain
  */
 protected function getVhostContent($domain, $ssl_vhost = false)
 {
     if ($ssl_vhost === true && ($domain['ssl_redirect'] != '1' && $domain['ssl'] != '1')) {
         return '';
     }
     $query = "SELECT * FROM `" . TABLE_PANEL_IPSANDPORTS . "` `i`, `" . TABLE_DOMAINTOIP . "` `dip`\n\t\t\tWHERE dip.id_domain = :domainid AND i.id = dip.id_ipandports ";
     if ($ssl_vhost === true && ($domain['ssl'] == '1' || $domain['ssl_redirect'] == '1')) {
         // by ordering by cert-file the row with filled out SSL-Fields will be shown last, thus it is enough to fill out 1 set of SSL-Fields
         $query .= "AND i.ssl = '1' ORDER BY i.ssl_cert_file ASC;";
     } else {
         $query .= "AND i.ssl = '0';";
     }
     $vhost_content = '';
     $result_stmt = Database::prepare($query);
     Database::pexecute($result_stmt, array('domainid' => $domain['id']));
     $ipportlist = '';
     $_vhost_content = '';
     while ($ipandport = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
         $ipport = '';
         $domain['ip'] = $ipandport['ip'];
         $domain['port'] = $ipandport['port'];
         if ($domain['ssl'] == '1') {
             $domain['ssl_cert_file'] = $ipandport['ssl_cert_file'];
             $domain['ssl_key_file'] = $ipandport['ssl_key_file'];
             $domain['ssl_ca_file'] = $ipandport['ssl_ca_file'];
             $domain['ssl_cert_chainfile'] = $ipandport['ssl_cert_chainfile'];
             // SSL STUFF
             $dssl = new DomainSSL();
             // this sets the ssl-related array-indices in the $domain array
             // if the domain has customer-defined ssl-certificates
             $dssl->setDomainSSLFilesArray($domain);
         }
         if (filter_var($domain['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
             $ipport = '[' . $domain['ip'] . ']:' . $domain['port'] . ' ';
         } else {
             $ipport = $domain['ip'] . ':' . $domain['port'] . ' ';
         }
         if ($ipandport['default_vhostconf_domain'] != '') {
             $_vhost_content .= $this->processSpecialConfigTemplate($ipandport['default_vhostconf_domain'], $domain, $domain['ip'], $domain['port'], $ssl_vhost) . "\n";
         }
         $ipportlist .= $ipport;
     }
     $vhost_content .= '<VirtualHost ' . trim($ipportlist) . '>' . "\n";
     $vhost_content .= $this->getServerNames($domain);
     if ($ssl_vhost == false && $domain['ssl'] == '1' && $domain['ssl_redirect'] == '1') {
         // We must not check if our port differs from port 443,
         // but if there is a destination-port != 443
         $_sslport = '';
         // This returns the first port that is != 443 with ssl enabled, if any
         // ordered by ssl-certificate (if any) so that the ip/port combo
         // with certificate is used
         $ssldestport_stmt = Database::prepare("\n\t\t\t\tSELECT `ip`.`port` FROM " . TABLE_PANEL_IPSANDPORTS . " `ip`\n\t\t\t\tLEFT JOIN `" . TABLE_DOMAINTOIP . "` `dip` ON (`ip`.`id` = `dip`.`id_ipandports`)\n\t\t\t\tWHERE `dip`.`id_domain` = :domainid\n\t\t\t\tAND `ip`.`ssl` = '1'  AND `ip`.`port` != 443\n\t\t\t\tORDER BY `ip`.`ssl_cert_file` DESC, `ip`.`port` LIMIT 1;\n\t\t\t");
         $ssldestport = Database::pexecute_first($ssldestport_stmt, array('domainid' => $domain['id']));
         if ($ssldestport['port'] != '') {
             $_sslport = ":" . $ssldestport['port'];
         }
         $domain['documentroot'] = 'https://' . $domain['domain'] . $_sslport . '/';
     }
     if ($ssl_vhost === true && $domain['ssl'] == '1' && Settings::Get('system.use_ssl') == '1') {
         if ($domain['ssl_cert_file'] == '') {
             $domain['ssl_cert_file'] = Settings::Get('system.ssl_cert_file');
         }
         if ($domain['ssl_key_file'] == '') {
             $domain['ssl_key_file'] = Settings::Get('system.ssl_key_file');
         }
         if ($domain['ssl_ca_file'] == '') {
             $domain['ssl_ca_file'] = Settings::Get('system.ssl_ca_file');
         }
         if ($domain['ssl_cert_chainfile'] == '') {
             $domain['ssl_cert_chainfile'] = Settings::Get('system.ssl_cert_chainfile');
         }
         if ($domain['ssl_cert_file'] != '') {
             $vhost_content .= '  SSLEngine On' . "\n";
             $vhost_content .= '  SSLProtocol ALL -SSLv2 -SSLv3' . "\n";
             // this makes it more secure, thx to Marcel (08/2013)
             $vhost_content .= '  SSLHonorCipherOrder On' . "\n";
             $vhost_content .= '  SSLCipherSuite ' . Settings::Get('system.ssl_cipher_list') . "\n";
             $vhost_content .= '  SSLVerifyDepth 10' . "\n";
             $vhost_content .= '  SSLCertificateFile ' . makeCorrectFile($domain['ssl_cert_file']) . "\n";
             if ($domain['ssl_key_file'] != '') {
                 $vhost_content .= '  SSLCertificateKeyFile ' . makeCorrectFile($domain['ssl_key_file']) . "\n";
             }
             if ($domain['ssl_ca_file'] != '') {
                 $vhost_content .= '  SSLCACertificateFile ' . makeCorrectFile($domain['ssl_ca_file']) . "\n";
             }
             if ($domain['ssl_cert_chainfile'] != '') {
                 $vhost_content .= '  SSLCertificateChainFile ' . makeCorrectFile($domain['ssl_cert_chainfile']) . "\n";
             }
         }
     }
     if (preg_match('/^https?\\:\\/\\//', $domain['documentroot'])) {
         $corrected_docroot = $this->idnaConvert->encode($domain['documentroot']);
         // Get domain's redirect code
         $code = getDomainRedirectCode($domain['id']);
         $modrew_red = '';
         if ($code != '') {
             $modrew_red = '[R=' . $code . ';L,NE]';
         }
         // redirect everything, not only root-directory, #541
         $vhost_content .= '  <IfModule mod_rewrite.c>' . "\n";
         $vhost_content .= '    RewriteEngine On' . "\n";
         if (!$ssl_vhost) {
             $vhost_content .= '    RewriteCond %{HTTPS} off' . "\n";
         }
         $vhost_content .= '    RewriteRule ^/(.*) ' . $corrected_docroot . '$1 ' . $modrew_red . "\n";
         $vhost_content .= '  </IfModule>' . "\n";
         $vhost_content .= '  Redirect ' . $code . ' / ' . $this->idnaConvert->encode($domain['documentroot']) . "\n";
     } else {
         mkDirWithCorrectOwnership($domain['customerroot'], $domain['documentroot'], $domain['guid'], $domain['guid'], true, true);
         $vhost_content .= $this->getWebroot($domain);
         if ($this->_deactivated == false) {
             $vhost_content .= $this->composePhpOptions($domain, $ssl_vhost);
             $vhost_content .= $this->getStats($domain);
         }
         $vhost_content .= $this->getLogfiles($domain);
         if ($domain['specialsettings'] != '') {
             $vhost_content .= $this->processSpecialConfigTemplate($domain['specialsettings'], $domain, $domain['ip'], $domain['port'], $ssl_vhost) . "\n";
         }
         if ($_vhost_content != '') {
             $vhost_content .= $_vhost_content;
         }
         if (Settings::Get('system.default_vhostconf') != '') {
             $vhost_content .= $this->processSpecialConfigTemplate(Settings::Get('system.default_vhostconf'), $domain, $domain['ip'], $domain['port'], $ssl_vhost) . "\n";
         }
     }
     $vhost_content .= '</VirtualHost>' . "\n";
     return $vhost_content;
 }
Example #29
0
        // get each row
        while ($row = $chk_stmt->fetch()) {
            // let htmlentities run over the language name and update the entry
            Database::pexecute($upd_stmt, array('lang' => htmlentities($row['language'])), false);
        }
        lastStepStatus(0);
    } else {
        lastStepStatus(1, "not needed");
    }
    showUpdateStep("Updating language descriptions to be in the native language");
    $upd_stmt = Database::prepare("UPDATE `" . TABLE_PANEL_LANGUAGE . "` SET `language` = :lang WHERE `iso` = :iso");
    Database::pexecute($upd_stmt, array('lang' => 'Fran&ccedil;ais', 'iso' => 'fr'), false);
    Database::pexecute($upd_stmt, array('lang' => 'Portugu&ecirc;s', 'iso' => 'pt'), false);
    Database::pexecute($upd_stmt, array('lang' => 'Italiano', 'iso' => 'it'), false);
    Database::pexecute($upd_stmt, array('lang' => 'Nederlands', 'iso' => 'nl'), false);
    Database::pexecute($upd_stmt, array('lang' => 'Svenska', 'iso' => 'sv'), false);
    lastStepStatus(0);
    updateToVersion('0.9.34-dev1');
}
if (isFroxlorVersion('0.9.34-dev1')) {
    showUpdateStep("Updating from 0.9.34-dev1 to 0.9.34-dev2", false);
    showUpdateStep("Adding new settings for apache-itk-mpm");
    Settings::AddNew("system.apacheitksupport", '0');
    lastStepStatus(0);
    showUpdateStep("Increase text-field size of domain-ssl table");
    Database::query("ALTER TABLE `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` MODIFY `ssl_cert_file` mediumtext NOT NULL");
    Database::query("ALTER TABLE `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` MODIFY `ssl_key_file` mediumtext NOT NULL");
    Database::query("ALTER TABLE `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` MODIFY `ssl_ca_file` mediumtext NOT NULL");
    Database::query("ALTER TABLE `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` MODIFY `ssl_cert_chainfile` mediumtext NOT NULL");
    lastStepStatus(0);
    updateToVersion('0.9.34-dev2');
Example #30
0
                }
                $log->logAction(USR_ACTION, LOG_INFO, "edited ftp-account '" . $result['username'] . "'");
                $description = validate($_POST['ftp_description'], 'description');
                $stmt = Database::prepare("UPDATE `" . TABLE_FTP_USERS . "`\n\t\t\t\t\tSET `description` = :desc\n\t\t\t\t\tWHERE `customerid` = :customerid\n\t\t\t\t\tAND `id` = :id");
                Database::pexecute($stmt, array("desc" => $description, "customerid" => $userinfo['customerid'], "id" => $id));
                redirectTo($filename, array('page' => $page, 's' => $s));
            } else {
                if (strpos($result['homedir'], $userinfo['documentroot']) === 0) {
                    $homedir = str_replace($userinfo['documentroot'], "/", $result['homedir']);
                } else {
                    $homedir = $result['homedir'];
                }
                $homedir = makeCorrectDir($homedir);
                $pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $homedir);
                if (Settings::Get('customer.ftpatdomain') == '1') {
                    $domains = '';
                    $result_domains_stmt = Database::prepare("SELECT `domain` FROM `" . TABLE_PANEL_DOMAINS . "`\n\t\t\t\t\t\tWHERE `customerid` = :customerid");
                    Database::pexecute($result_domains_stmt, array("customerid" => $userinfo['customerid']));
                    while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) {
                        $domains .= makeoption($idna_convert->decode($row_domain['domain']), $row_domain['domain']);
                    }
                }
                $ftp_edit_data = (include_once dirname(__FILE__) . '/lib/formfields/customer/ftp/formfield.ftp_edit.php');
                $ftp_edit_form = htmlform::genHTMLForm($ftp_edit_data);
                $title = $ftp_edit_data['ftp_edit']['title'];
                $image = $ftp_edit_data['ftp_edit']['image'];
                eval("echo \"" . getTemplate('ftp/accounts_edit') . "\";");
            }
        }
    }
}