当前位置: 首页>>代码示例>>PHP>>正文


PHP makeCorrectDir函数代码示例

本文整理汇总了PHP中makeCorrectDir函数的典型用法代码示例。如果您正苦于以下问题:PHP makeCorrectDir函数的具体用法?PHP makeCorrectDir怎么用?PHP makeCorrectDir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了makeCorrectDir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: storeDefaultIndex

/**
 * 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)
{
    global $db, $settings, $pathtophpfiles;
    if ($force || (int) $settings['system']['store_index_file_subs'] == 1) {
        $result = $db->query("SELECT `t`.`value`, `c`.`email` AS `customer_email`, `a`.`email` AS `admin_email`, `c`.`loginname` AS `customer_login`, `a`.`loginname` AS `admin_login` FROM `" . TABLE_PANEL_CUSTOMERS . "` AS `c` INNER JOIN `" . TABLE_PANEL_ADMINS . "` AS `a` ON `c`.`adminid` = `a`.`adminid` INNER JOIN `" . TABLE_PANEL_TEMPLATES . "` AS `t` ON `a`.`adminid` = `t`.`adminid` WHERE `varname` = 'index_html' AND `c`.`loginname` = '" . $db->escape($loginname) . "'");
        if ($db->num_rows($result) > 0) {
            $template = $db->fetch_array($result);
            $replace_arr = array('SERVERNAME' => $settings['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['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['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 ' . $pathtophpfiles . '/templates/misc/standardcustomer/* ' . escapeshellarg($destination));
            }
            safe_exec('cp -a ' . $pathtophpfiles . '/templates/misc/standardcustomer/* ' . escapeshellarg($destination));
        }
    }
    return;
}
开发者ID:Alkyoneus,项目名称:Froxlor,代码行数:36,代码来源:function.storeDefaultIndex.php

示例2: findDirs

/**
 * Returns an array of found directories
 *
 * This function checks every found directory if they match either $uid or $gid, if they do
 * the found directory is valid. It uses recursive-iterators to find subdirectories.
 *
 * @param  string $path the path to start searching in
 * @param  int $uid the uid which must match the found directories
 * @param  int $gid the gid which must match the found direcotries
 *
 * @return array Array of found valid paths
 */
function findDirs($path, $uid, $gid)
{
    $_fileList = array();
    $path = makeCorrectDir($path);
    // valid directory?
    if (is_dir($path)) {
        try {
            // create RecursiveIteratorIterator
            $its = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
            // we can limit the recursion-depth, but will it be helpful or
            // will people start asking "why do I only see 2 subdirectories, i want to use /a/b/c"
            // let's keep this in mind and see whether it will be useful
            // @TODO
            // $its->setMaxDepth(2);
            // check every file
            foreach ($its as $fullFileName => $it) {
                if ($it->isDir() && (fileowner($fullFileName) == $uid || filegroup($fullFileName) == $gid)) {
                    $_fileList[] = makeCorrectDir(dirname($fullFileName));
                }
            }
        } catch (UnexpectedValueException $e) {
            // this is thrown if the directory is not found or not readble etc.
            // just ignore and keep going
        }
    }
    return array_unique($_fileList);
}
开发者ID:mowamed,项目名称:Froxlor,代码行数:39,代码来源:function.findDirs.php

示例3: checkPathConflicts

/**
 * 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     Froxlor team <team@froxlor.org> (2010-)
 * @license    GPLv2 http://files.froxlor.org/misc/COPYING.txt
 * @package    Functions
 *
 */
function checkPathConflicts($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues)
{
    global $settings;
    if ((int) $settings['system']['mod_fcgid'] == 1) {
        /**
         * fcgid-configdir has changed ->
         * check against customer-doc-prefix
         */
        if ($fieldname == "system_mod_fcgid_configdir") {
            $newdir = makeCorrectDir($newfieldvalue);
            $cdir = makeCorrectDir($settings['system']['documentroot_prefix']);
        } elseif ($fieldname == "system_documentroot_prefix") {
            $newdir = makeCorrectDir($newfieldvalue);
            $cdir = makeCorrectDir($settings['system']['mod_fcgid_configdir']);
        }
        // neither dir can be within the other nor can they be equal
        if (substr($newdir, 0, strlen($cdir)) == $cdir || substr($cdir, 0, strlen($newdir)) == $newdir || $newdir == $cdir) {
            $returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_ERROR, 'fcgidpathcannotbeincustomerdoc');
        } else {
            $returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_OK);
        }
    } else {
        $returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_OK);
    }
    return $returnvalue;
}
开发者ID:Alkyoneus,项目名称:Froxlor,代码行数:40,代码来源:function.checkPathConflicts.php

示例4: createOwnVhostStarter

 public function createOwnVhostStarter()
 {
     if ($this->settings['system']['mod_fcgid_ownvhost'] == '1' || $this->settings['phpfpm']['enabled'] == '1' && $this->settings['phpfpm']['enabled_ownvhost'] == '1') {
         $mypath = makeCorrectDir(dirname(dirname(dirname(__FILE__))));
         // /var/www/froxlor, needed for chown
         if ($this->settings['system']['mod_fcgid_ownvhost'] == '1') {
             $user = $this->settings['system']['mod_fcgid_httpuser'];
             $group = $this->settings['system']['mod_fcgid_httpgroup'];
         } elseif ($this->settings['phpfpm']['enabled'] == '1' && $this->settings['phpfpm']['enabled_ownvhost'] == '1') {
             $user = $this->settings['phpfpm']['vhost_httpuser'];
             $group = $this->settings['phpfpm']['vhost_httpgroup'];
         }
         $domain = array('id' => 'none', 'domain' => $this->settings['system']['hostname'], 'adminid' => 1, 'mod_fcgid_starter' => -1, 'mod_fcgid_maxrequests' => -1, 'guid' => $user, 'openbasedir' => 0, 'safemode' => '0', 'email' => $this->settings['panel']['adminmail'], 'loginname' => 'froxlor.panel', 'documentroot' => $mypath);
         // all the files and folders have to belong to the local user
         // now because we also use fcgid for our own vhost
         safe_exec('chown -R ' . $user . ':' . $group . ' ' . escapeshellarg($mypath));
         // get php.ini for our own vhost
         $php = new phpinterface($this->getDB(), $this->settings, $domain);
         // @FIXME don't use fcgid settings if not fcgid in use, but we don't have anything else atm
         $phpconfig = $php->getPhpConfig($this->settings['system']['mod_fcgid_defaultini_ownvhost']);
         // create starter-file | config-file
         $php->getInterface()->createConfig($phpconfig);
         // create php.ini
         // @TODO make php-fpm support this
         $php->getInterface()->createIniFile($phpconfig);
     }
 }
开发者ID:rtznprmpftl,项目名称:Froxlor,代码行数:27,代码来源:cron_tasks.inc.http.15.apache_fcgid.php

示例5: getThemes

/**
 * returns an array for the settings-array
 *
 * @return array
 */
function getThemes()
{
    $themespath = makeCorrectDir(FROXLOR_INSTALL_DIR . '/templates/');
    $themes_available = array();
    if (is_dir($themespath)) {
        $its = new DirectoryIterator($themespath);
        foreach ($its as $it) {
            if ($it->isDir() && $it->getFilename() != '.' && $it->getFilename() != '..' && $it->getFilename() != 'misc') {
                $theme = $themespath . $it->getFilename();
                if (file_exists($theme . '/config.json')) {
                    $themeconfig = json_decode(file_get_contents($theme . '/config.json'), true);
                    if (array_key_exists('variants', $themeconfig) && is_array($themeconfig['variants'])) {
                        foreach ($themeconfig['variants'] as $variant => $data) {
                            if ($variant == "default") {
                                $themes_available[$it->getFilename()] = $it->getFilename();
                            } elseif (array_key_exists('description', $data)) {
                                $themes_available[$it->getFilename() . '_' . $variant] = $data['description'];
                            } else {
                                $themes_available[$it->getFilename() . '_' . $variant] = $it->getFilename() . ' (' . $variant . ')';
                            }
                        }
                    } else {
                        $themes_available[$it->getFilename()] = $it->getFilename();
                    }
                }
            }
        }
    }
    return $themes_available;
}
开发者ID:cobrafast,项目名称:Froxlor,代码行数:35,代码来源:function.getThemes.php

示例6: findDirs

/**
 * Returns an array of found directories
 *
 * This function checks every found directory if they match either $uid or $gid, if they do
 * the found directory is valid. It uses recursive function calls to find subdirectories. Due
 * to the recursive behauviour this function may consume much memory.
 *
 * @param  string   path       The path to start searching in
 * @param  integer  uid        The uid which must match the found directories
 * @param  integer  gid        The gid which must match the found direcotries
 * @param  array    _fileList  recursive transport array !for internal use only!
 * @return array    Array of found valid pathes
 *
 * @author Martin Burchert  <martin.burchert@syscp.de>
 * @author Manuel Bernhardt <manuel.bernhardt@syscp.de>
 */
function findDirs($path, $uid, $gid)
{
    $list = array($path);
    $_fileList = array();
    while (sizeof($list) > 0) {
        $path = array_pop($list);
        $path = makeCorrectDir($path);
        if (!is_readable($path) || !is_executable($path)) {
            //return $_fileList;
            // only 'skip' this directory, #611
            continue;
        }
        $dh = opendir($path);
        if ($dh === false) {
            /*
             * this should never be called because we checked
             * 'is_readable' before...but we never know what might happen
             */
            standard_error('cannotreaddir', $path);
            return null;
        } else {
            while (false !== ($file = @readdir($dh))) {
                if ($file == '.' && (fileowner($path . '/' . $file) == $uid || filegroup($path . '/' . $file) == $gid)) {
                    $_fileList[] = makeCorrectDir($path);
                }
                if (is_dir($path . '/' . $file) && $file != '..' && $file != '.') {
                    array_push($list, $path . '/' . $file);
                }
            }
            @closedir($dh);
        }
    }
    return $_fileList;
}
开发者ID:Git-Host,项目名称:Froxlor,代码行数:50,代码来源:function.findDirs.php

示例7: writeConfigs

 public function writeConfigs()
 {
     // tell the world what we are doing
     $this->_logger->logAction(CRON_ACTION, LOG_INFO, 'Task4 started - Rebuilding froxlor_bind.conf');
     // clean up
     $this->_cleanZonefiles();
     // check for subfolder in bind-config-directory
     if (!file_exists(makeCorrectDir(Settings::Get('system.bindconf_directory') . '/domains/'))) {
         $this->_logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.bindconf_directory') . '/domains/')));
         safe_exec('mkdir -p ' . escapeshellarg(makeCorrectDir(Settings::Get('system.bindconf_directory') . '/domains/')));
     }
     $domains = $this->getDomainList();
     if (empty($domains)) {
         $this->_logger->logAction(CRON_ACTION, LOG_INFO, 'No domains found for nameserver-config, skipping...');
         return;
     }
     $bindconf_file = '# ' . Settings::Get('system.bindconf_directory') . 'froxlor_bind.conf' . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" . '# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n\n";
     foreach ($domains as $domain) {
         if ($domain['ismainbutsubto'] > 0) {
             // domains with ismainbutsubto>0 are handled by recursion within walkDomainList()
             continue;
         }
         $this->walkDomainList($domain, $domains);
     }
     $bindconf_file_handler = fopen(makeCorrectFile(Settings::Get('system.bindconf_directory') . '/froxlor_bind.conf'), 'w');
     fwrite($bindconf_file_handler, $this->_bindconf_file);
     fclose($bindconf_file_handler);
     $this->_logger->logAction(CRON_ACTION, LOG_INFO, 'froxlor_bind.conf written');
     $this->reloadDaemon();
     $this->_logger->logAction(CRON_ACTION, LOG_INFO, 'Task4 finished');
 }
开发者ID:asemen,项目名称:Froxlor,代码行数:31,代码来源:cron_tasks.inc.dns.10.bind.php

示例8: makePathfield

/**
 * Returns a valid html tag for the choosen $fieldType for pathes
 *
 * @param  string   path       The path to start searching in
 * @param  integer  uid        The uid which must match the found directories
 * @param  integer  gid        The gid which must match the found direcotries
 * @param  string   fieldType  Either "Manual" or "Dropdown"
 * @return string   The html tag for the choosen $fieldType
 *
 * @author Martin Burchert  <martin.burchert@syscp.de>
 * @author Manuel Bernhardt <manuel.bernhardt@syscp.de>
 */
function makePathfield($path, $uid, $gid, $fieldType, $value = '')
{
    global $lng;
    $value = str_replace($path, '', $value);
    $field = '';
    if ($fieldType == 'Manual') {
        $field = '<input type="text" name="path" value="' . htmlspecialchars($value) . '" size="30" />';
    } elseif ($fieldType == 'Dropdown') {
        $dirList = findDirs($path, $uid, $gid);
        natcasesort($dirList);
        if (sizeof($dirList) > 0) {
            $field = '<select name="path">';
            foreach ($dirList as $key => $dir) {
                if (strpos($dir, $path) === 0) {
                    $dir = makeCorrectDir(substr($dir, strlen($path)));
                }
                $field .= makeoption($dir, $dir, $value);
            }
            $field .= '</select>';
        } else {
            $field = $lng['panel']['dirsmissing'];
            $field .= '<input type="hidden" name="path" value="/" />';
        }
    }
    return $field;
}
开发者ID:HobbyNToys,项目名称:SysCP,代码行数:38,代码来源:function.makePathfield.php

示例9: createOwnVhostStarter

 public function createOwnVhostStarter()
 {
     if (Settings::Get('phpfpm.enabled') == '1' && Settings::Get('phpfpm.enabled_ownvhost') == '1') {
         $mypath = makeCorrectDir(dirname(dirname(dirname(__FILE__))));
         // /var/www/froxlor, needed for chown
         $user = Settings::Get('phpfpm.vhost_httpuser');
         $group = Settings::Get('phpfpm.vhost_httpgroup');
         $domain = array('id' => 'none', 'domain' => Settings::Get('system.hostname'), 'adminid' => 1, 'mod_fcgid_starter' => -1, 'mod_fcgid_maxrequests' => -1, 'guid' => $user, 'openbasedir' => 0, 'email' => Settings::Get('panel.adminmail'), 'loginname' => 'froxlor.panel', 'documentroot' => $mypath);
         // all the files and folders have to belong to the local user
         // now because we also use fcgid for our own vhost
         safe_exec('chown -R ' . $user . ':' . $group . ' ' . escapeshellarg($mypath));
         // get php.ini for our own vhost
         $php = new phpinterface($domain);
         // get php-config
         if (Settings::Get('phpfpm.enabled') == '1') {
             // fpm
             $phpconfig = $php->getPhpConfig(Settings::Get('phpfpm.vhost_defaultini'));
         } else {
             // fcgid
             $phpconfig = $php->getPhpConfig(Settings::Get('system.mod_fcgid_defaultini_ownvhost'));
         }
         // create starter-file | config-file
         $php->getInterface()->createConfig($phpconfig);
         // create php.ini (fpm does nothing here, as it
         // defines ini-settings in its pool config)
         $php->getInterface()->createIniFile($phpconfig);
     }
 }
开发者ID:Git-Host,项目名称:Froxlor,代码行数:28,代码来源:cron_tasks.inc.http.35.nginx_phpfpm.php

示例10: storeDefaultIndex

/**
 * 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;
}
开发者ID:cobrafast,项目名称:Froxlor,代码行数:36,代码来源:function.storeDefaultIndex.php

示例11: findDirs

/**
 * Returns an array of found directories
 *
 * This function checks every found directory if they match either $uid or $gid, if they do
 * the found directory is valid. It uses recursive function calls to find subdirectories. Due
 * to the recursive behauviour this function may consume much memory.
 *
 * @param  string   path       The path to start searching in
 * @param  integer  uid        The uid which must match the found directories
 * @param  integer  gid        The gid which must match the found direcotries
 * @param  array    _fileList  recursive transport array !for internal use only!
 * @return array    Array of found valid pathes
 *
 * @author Martin Burchert  <martin.burchert@syscp.de>
 * @author Manuel Bernhardt <manuel.bernhardt@syscp.de>
 */
function findDirs($path, $uid, $gid)
{
    $list = array($path);
    $_fileList = array();
    while (sizeof($list) > 0) {
        $path = array_pop($list);
        $path = makeCorrectDir($path);
        $dh = opendir($path);
        if ($dh === false) {
            standard_error('cannotreaddir', $path);
            return null;
        } else {
            while (false !== ($file = @readdir($dh))) {
                if ($file == '.' && (fileowner($path . '/' . $file) == $uid || filegroup($path . '/' . $file) == $gid)) {
                    $_fileList[] = makeCorrectDir($path);
                }
                if (is_dir($path . '/' . $file) && $file != '..' && $file != '.') {
                    array_push($list, $path . '/' . $file);
                }
            }
            @closedir($dh);
        }
    }
    return $_fileList;
}
开发者ID:HobbyNToys,项目名称:SysCP,代码行数:41,代码来源:function.findDirs.php

示例12: setDomainSSLFilesArray

 /**
  * read domain-related (or if empty, parentdomain-related) ssl-certificates from the database
  * and (if not empty) set the corresponding array-indices (ssl_cert_file, ssl_key_file,
  * ssl_ca_file and ssl_cert_chainfile). Hence the parameter as reference.
  *
  * @param array $domain domain-array as reference so we can set the corresponding array-indices
  *
  * @return null
  */
 public function setDomainSSLFilesArray(array &$domain = null)
 {
     // check if the domain itself has a certificate defined
     $dom_certs_stmt = Database::prepare("\n\t\t\tSELECT * FROM `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` WHERE `domainid` = :domid\n\t\t");
     $dom_certs = Database::pexecute_first($dom_certs_stmt, array('domid' => $domain['id']));
     if (!is_array($dom_certs) || !isset($dom_certs['ssl_cert_file']) || $dom_certs['ssl_cert_file'] == '') {
         // maybe its parent?
         if ($domain['parentdomainid'] != null) {
             $dom_certs = Database::pexecute_first($dom_certs_stmt, array('domid' => $domain['parentdomainid']));
         }
     }
     // check if it's an array and if the most important field is set
     if (is_array($dom_certs) && isset($dom_certs['ssl_cert_file']) && $dom_certs['ssl_cert_file'] != '') {
         // get destination path
         $sslcertpath = makeCorrectDir(Settings::Get('system.customer_ssl_path'));
         // create path if it does not exist
         if (!file_exists($sslcertpath)) {
             safe_exec('mkdir -p ' . escapeshellarg($sslcertpath));
         }
         // make correct files for the certificates
         $ssl_files = array('ssl_cert_file' => makeCorrectFile($sslcertpath . '/' . $domain['domain'] . '.crt'), 'ssl_key_file' => makeCorrectFile($sslcertpath . '/' . $domain['domain'] . '.key'));
         if (Settings::Get('system.webserver') == 'lighttpd') {
             // put my.crt and my.key together for lighty.
             $dom_certs['ssl_cert_file'] = trim($dom_certs['ssl_cert_file']) . "\n" . trim($dom_certs['ssl_key_file']) . "\n";
             $ssl_files['ssl_key_file'] = '';
         }
         // initialize optional files
         $ssl_files['ssl_ca_file'] = '';
         $ssl_files['ssl_cert_chainfile'] = '';
         // set them if they are != empty
         if ($dom_certs['ssl_ca_file'] != '') {
             $ssl_files['ssl_ca_file'] = makeCorrectFile($sslcertpath . '/' . $domain['domain'] . '_CA.pem');
         }
         if ($dom_certs['ssl_cert_chainfile'] != '') {
             if (Settings::Get('system.webserver') == 'nginx') {
                 // put ca.crt in my.crt, as nginx does not support a separate chain file.
                 $dom_certs['ssl_cert_file'] = trim($dom_certs['ssl_cert_file']) . "\n" . trim($dom_certs['ssl_cert_chainfile']) . "\n";
             } else {
                 $ssl_files['ssl_cert_chainfile'] = makeCorrectFile($sslcertpath . '/' . $domain['domain'] . '_chain.pem');
             }
         }
         // create them on the filesystem
         foreach ($ssl_files as $type => $filename) {
             if ($filename != '') {
                 touch($filename);
                 $_fh = fopen($filename, 'w');
                 fwrite($_fh, $dom_certs[$type]);
                 fclose($_fh);
                 chmod($filename, 0600);
             }
         }
         // override corresponding array values
         $domain['ssl_cert_file'] = $ssl_files['ssl_cert_file'];
         $domain['ssl_key_file'] = $ssl_files['ssl_key_file'];
         $domain['ssl_ca_file'] = $ssl_files['ssl_ca_file'];
         $domain['ssl_cert_chainfile'] = $ssl_files['ssl_cert_chainfile'];
     }
     return;
 }
开发者ID:greybyte,项目名称:froxlor-mn,代码行数:68,代码来源:class.DomainSSL.php

示例13: createAWStatsConf

/**
 * Create or modify the AWStats configuration file for the given domain.
 * Modified by Berend Dekens to allow custom configurations.
 *
 * @param logFile
 * @param siteDomain
 * @param hostAliases
 * @return null
 */
function createAWStatsConf($logFile, $siteDomain, $hostAliases, $customerDocroot, $awstats_params = array())
{
    global $pathtophpfiles, $settings;
    // Generation header
    $header = "## GENERATED BY FROXLOR\n";
    $header2 = "## Do not remove the line above! This tells Froxlor to update this configuration\n## If you wish to manually change this configuration file, remove the first line to make sure Froxlor won't rebuild this file\n## Generated for domain {SITE_DOMAIN} on " . date('l dS \\of F Y h:i:s A') . "\n";
    $awstats_dir = makeCorrectDir($customerDocroot . '/awstats/' . $siteDomain . '/');
    if (!is_dir($awstats_dir)) {
        safe_exec('mkdir -p ' . escapeshellarg($awstats_dir));
    }
    // chown created folder, #258
    makeChownWithNewStats($awstats_params);
    // weird but could happen...
    if (!is_dir($settings['system']['awstats_conf'])) {
        safe_exec('mkdir -p ' . escapeshellarg($settings['system']['awstats_conf']));
    }
    // These are the variables we will replace
    $regex = array('/\\{LOG_FILE\\}/', '/\\{SITE_DOMAIN\\}/', '/\\{HOST_ALIASES\\}/', '/\\{CUSTOMER_DOCROOT\\}/', '/\\{AWSTATS_CONF\\}/');
    $replace = array(makeCorrectFile($logFile), $siteDomain, $hostAliases, $awstats_dir, makeCorrectDir($settings['system']['awstats_conf']));
    // File names
    $domain_file = makeCorrectFile($settings['system']['awstats_conf'] . '/awstats.' . $siteDomain . '.conf');
    $model_file = dirname(dirname(dirname(dirname(__FILE__))));
    $model_file .= '/templates/misc/awstatsmodel/';
    if ($settings['system']['mod_log_sql'] == '1') {
        $model_file .= 'awstats.froxlor.model_log_sql.conf';
    } else {
        $model_file .= 'awstats.froxlor.model.conf';
    }
    $model_file = makeCorrectFile($model_file);
    // Test if the file exists
    if (file_exists($domain_file)) {
        // Check for the generated header - if this is a manual modification we won't update
        $awstats_domain_conf = fopen($domain_file, 'r');
        if (fgets($awstats_domain_conf, strlen($header)) != $header) {
            fclose($awstats_domain_conf);
            return;
        }
        // Close the file
        fclose($awstats_domain_conf);
    }
    $awstats_domain_conf = fopen($domain_file, 'w');
    $awstats_model_conf = fopen($model_file, 'r');
    // Write the header
    fwrite($awstats_domain_conf, $header);
    fwrite($awstats_domain_conf, preg_replace($regex, $replace, $header2));
    // Write the configuration file
    while (($line = fgets($awstats_model_conf, 4096)) !== false) {
        if (!preg_match('/^#/', $line) && trim($line) != '') {
            fwrite($awstats_domain_conf, preg_replace($regex, $replace, $line));
        }
    }
    fclose($awstats_domain_conf);
    fclose($awstats_model_conf);
}
开发者ID:Alkyoneus,项目名称:Froxlor,代码行数:63,代码来源:function.createAWStatsConf.php

示例14: appendOpenBasedirPath

/**
 * checks give path for security issues
 * and returns a string that can be appended
 * to a line for a open_basedir directive
 * 
 * @param string  $path  the path to check and append
 * @param boolean $first if true, no ':' will be prefixed to the path
 * 
 * @return string
 */
function appendOpenBasedirPath($path = '', $first = false)
{
    $path = makeCorrectDir($path);
    if ($path != '' && $path != '/' && !preg_match("#^/dev#i", $path) && !preg_match("#^/proc#i", $path) && !preg_match("#^/etc#i", $path) && !preg_match("#^/sys#i", $path) && !preg_match("#:#", $path)) {
        if ($first) {
            return $path;
        }
        return ':' . $path;
    }
    return '';
}
开发者ID:Alkyoneus,项目名称:Froxlor,代码行数:21,代码来源:function.appendOpenbasedirPath.php

示例15: mkDirWithCorrectOwnership

/**
 * Creates a directory below a users homedir and sets all directories,
 * which had to be created below with correct Owner/Group
 * (Copied from cron_tasks.php:rev1189 as we'll need this more often in future)
 *
 * @param  string The homedir of the user
 * @param  string The dir which should be created
 * @param  int    The uid of the user
 * @param  int    The gid of the user
 * @param  bool   Place standard-index.html into the new folder
 * @param  bool   Allow creating a directory out of the customers docroot
 * 
 * @return bool   true if everything went okay, false if something went wrong
 *
 * @author Florian Lippert <flo@syscp.org>
 * @author Martin Burchert <martin.burchert@syscp.org>
 */
function mkDirWithCorrectOwnership($homeDir, $dirToCreate, $uid, $gid, $placeindex = false, $allow_notwithinhomedir = false, $setgid = false)
{
    $returncode = true;
    if ($homeDir != '' && $dirToCreate != '') {
        $homeDir = makeCorrectDir($homeDir);
        $dirToCreate = makeCorrectDir($dirToCreate);
        if (substr($dirToCreate, 0, strlen($homeDir)) == $homeDir) {
            $subdir = substr($dirToCreate, strlen($homeDir) - 1);
            $within_homedir = true;
        } else {
            $subdir = $dirToCreate;
            $within_homedir = false;
        }
        $subdir = makeCorrectDir($subdir);
        $subdirs = array();
        if ($within_homedir || !$allow_notwithinhomedir) {
            $subdirlen = strlen($subdir);
            $offset = 0;
            while ($offset < $subdirlen) {
                $offset = strpos($subdir, '/', $offset);
                $subdirelem = substr($subdir, 0, $offset);
                $offset++;
                array_push($subdirs, makeCorrectDir($homeDir . $subdirelem));
            }
        } else {
            array_push($subdirs, $dirToCreate);
        }
        $subdirs = array_unique($subdirs);
        sort($subdirs);
        foreach ($subdirs as $sdir) {
            if (!is_dir($sdir)) {
                $sdir = makeCorrectDir($sdir);
                safe_exec('mkdir -p ' . escapeshellarg($sdir));
                /**
                 * #68
                 */
                if ($placeindex) {
                    $loginname = getLoginNameByUid($uid);
                    if ($loginname !== false) {
                        storeDefaultIndex($loginname, $sdir, null);
                    }
                }
                safe_exec('chown -R ' . (int) $uid . ':' . $gid . ' ' . escapeshellarg($sdir));
                if ($setgid) {
                    safe_exec('chmod g+s ' . escapeshellarg($sdir));
                }
            }
        }
    } else {
        $returncode = false;
    }
    return $returncode;
}
开发者ID:greybyte,项目名称:froxlor-mn,代码行数:70,代码来源:function.mkDirWithCorrectOwnership.php


注:本文中的makeCorrectDir函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。