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


PHP safe_exec函数代码示例

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


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

示例1: process

 function process($tmp_filename)
 {
     $pdf_file = $tmp_filename . '.pdf';
     safe_exec($this->_mk_cmd($tmp_filename), $output);
     unlink($tmp_filename);
     return $pdf_file;
 }
开发者ID:isantiago,项目名称:foswiki,代码行数:7,代码来源:filter.output.ps2pdf.class.php

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: createOwnVhostStarter

 public function createOwnVhostStarter()
 {
     if ($this->settings['phpfpm']['enabled'] == '1' && $this->settings['phpfpm']['enabled_ownvhost'] == '1') {
         $mypath = makeCorrectDir(dirname(dirname(dirname(__FILE__))));
         // /var/www/froxlor, needed for chown
         $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, 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:Alkyoneus,项目名称:Froxlor,代码行数:22,代码来源:cron_tasks.inc.http.35.nginx_phpfpm.php

示例9: makeChownWithNewStats

/**
 * chowns either awstats or webalizer folder,
 * either with webserver-user or - if fcgid
 * is used - the customers name, #258
 *
 * @param array $row array if panel_customers
 *
 * @return void
 */
function makeChownWithNewStats($row)
{
    // get correct user
    if ((Settings::Get('system.mod_fcgid') == '1' || Settings::Get('phpfpm.enabled') == '1') && isset($row['deactivated']) && $row['deactivated'] == '0') {
        $user = $row['loginname'];
        $group = $row['loginname'];
    } else {
        $user = $row['guid'];
        $group = $row['guid'];
    }
    // get correct directory
    $dir = $row['documentroot'];
    if (Settings::Get('system.awstats_enabled') == '1') {
        $dir .= '/awstats/';
    } else {
        $dir .= '/webalizer/';
    }
    // only run chown if directory exists
    if (file_exists($dir)) {
        // run chown
        safe_exec('chown -R ' . escapeshellarg($user) . ':' . escapeshellarg($group) . ' ' . escapeshellarg(makeCorrectDir($dir)));
    }
}
开发者ID:cobrafast,项目名称:Froxlor,代码行数:32,代码来源:function.makeChownWithNewStats.php

示例10: 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
 *
 * @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)
{
    $returncode = true;
    if ($homeDir != '' && $dirToCreate != '') {
        $homeDir = makeCorrectDir($homeDir);
        $dirToCreate = makeCorrectDir($dirToCreate);
        if (substr($dirToCreate, 0, strlen($homeDir)) == $homeDir) {
            $subdir = substr($dirToCreate, strlen($homeDir));
        } else {
            $subdir = $dirToCreate;
        }
        $subdir = makeCorrectDir($subdir);
        $subdirlen = strlen($subdir);
        $subdirs = array();
        array_push($subdirs, $dirToCreate);
        $offset = 0;
        while ($offset < $subdirlen) {
            $offset = strpos($subdir, '/', $offset);
            $subdirelem = substr($subdir, 0, $offset);
            ++$offset;
            array_push($subdirs, makeCorrectDir($homeDir . $subdirelem));
        }
        $subdirs = array_unique($subdirs);
        sort($subdirs);
        foreach ($subdirs as $sdir) {
            if (!is_dir($sdir)) {
                $sdir = makeCorrectDir($sdir);
                safe_exec('mkdir -p ' . escapeshellarg($sdir));
                safe_exec('chown -R ' . (int) $uid . ':' . (int) $gid . ' ' . escapeshellarg($sdir));
            }
        }
    } else {
        $returncode = false;
    }
    return $returncode;
}
开发者ID:markc,项目名称:syscp,代码行数:51,代码来源:function.mkDirWithCorrectOwnership.php

示例11: getAliasConfigDir

 /**
  * fastcgi-fakedirectory directory
  *
  * @param boolean $createifnotexists create the directory if it does not exist
  *
  * @return string the directory
  */
 public function getAliasConfigDir($createifnotexists = true)
 {
     // ensure default...
     if (Settings::Get('phpfpm.aliasconfigdir') == null) {
         Settings::Set('phpfpm.aliasconfigdir', '/var/www/php-fpm');
     }
     $configdir = makeCorrectDir(Settings::Get('phpfpm.aliasconfigdir') . '/' . $this->_domain['loginname'] . '/' . $this->_domain['domain'] . '/');
     if (!is_dir($configdir) && $createifnotexists) {
         safe_exec('mkdir -p ' . escapeshellarg($configdir));
         safe_exec('chown ' . $this->_domain['guid'] . ':' . $this->_domain['guid'] . ' ' . escapeshellarg($configdir));
     }
     return $configdir;
 }
开发者ID:Git-Host,项目名称:Froxlor,代码行数:20,代码来源:class.phpinterface_fpm.php

示例12: writeDKIMconfigs

 public function writeDKIMconfigs()
 {
     if (Settings::Get('dkim.use_dkim') == '1') {
         if (!file_exists(makeCorrectDir(Settings::Get('dkim.dkim_prefix')))) {
             $this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir -p ' . escapeshellarg(makeCorrectDir(Settings::Get('dkim.dkim_prefix'))));
             safe_exec('mkdir -p ' . escapeshellarg(makeCorrectDir(Settings::Get('dkim.dkim_prefix'))));
         }
         $dkimdomains = '';
         $dkimkeys = '';
         $result_domains_stmt = Database::query("\n\t\t\t\tSELECT `id`, `domain`, `dkim`, `dkim_id`, `dkim_pubkey`, `dkim_privkey`\n\t\t\t\tFROM `" . TABLE_PANEL_DOMAINS . "` WHERE `dkim` = '1' ORDER BY `id` ASC\n\t\t\t");
         while ($domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) {
             $privkey_filename = makeCorrectFile(Settings::Get('dkim.dkim_prefix') . '/dkim_' . $domain['dkim_id']);
             $pubkey_filename = makeCorrectFile(Settings::Get('dkim.dkim_prefix') . '/dkim_' . $domain['dkim_id'] . '.public');
             if ($domain['dkim_privkey'] == '' || $domain['dkim_pubkey'] == '') {
                 $max_dkim_id_stmt = Database::query("SELECT MAX(`dkim_id`) as `max_dkim_id` FROM `" . TABLE_PANEL_DOMAINS . "`");
                 $max_dkim_id = $max_dkim_id_stmt->fetch(PDO::FETCH_ASSOC);
                 $domain['dkim_id'] = (int) $max_dkim_id['max_dkim_id'] + 1;
                 $privkey_filename = makeCorrectFile(Settings::Get('dkim.dkim_prefix') . '/dkim_' . $domain['dkim_id']);
                 safe_exec('openssl genrsa -out ' . escapeshellarg($privkey_filename) . ' ' . Settings::Get('dkim.dkim_keylength'));
                 $domain['dkim_privkey'] = file_get_contents($privkey_filename);
                 safe_exec("chmod 0640 " . escapeshellarg($privkey_filename));
                 $pubkey_filename = makeCorrectFile(Settings::Get('dkim.dkim_prefix') . '/dkim_' . $domain['dkim_id'] . '.public');
                 safe_exec('openssl rsa -in ' . escapeshellarg($privkey_filename) . ' -pubout -outform pem -out ' . escapeshellarg($pubkey_filename));
                 $domain['dkim_pubkey'] = file_get_contents($pubkey_filename);
                 safe_exec("chmod 0664 " . escapeshellarg($pubkey_filename));
                 $upd_stmt = Database::prepare("\n\t\t\t\t\t\tUPDATE `" . TABLE_PANEL_DOMAINS . "` SET\n\t\t\t\t\t\t`dkim_id` = :dkimid,\n\t\t\t\t\t\t`dkim_privkey` = :privkey,\n\t\t\t\t\t\t`dkim_pubkey` = :pubkey\n\t\t\t\t\t\tWHERE `id` = :id\n\t\t\t\t\t");
                 $upd_data = array('dkimid' => $domain['dkim_id'], 'privkey' => $domain['dkim_privkey'], 'pubkey' => $domain['dkim_pubkey'], 'id' => $domain['id']);
                 Database::pexecute($upd_stmt, $upd_data);
             }
             if (!file_exists($privkey_filename) && $domain['dkim_privkey'] != '') {
                 $privkey_file_handler = fopen($privkey_filename, "w");
                 fwrite($privkey_file_handler, $domain['dkim_privkey']);
                 fclose($privkey_file_handler);
                 safe_exec("chmod 0640 " . escapeshellarg($privkey_filename));
             }
             if (!file_exists($pubkey_filename) && $domain['dkim_pubkey'] != '') {
                 $pubkey_file_handler = fopen($pubkey_filename, "w");
                 fwrite($pubkey_file_handler, $domain['dkim_pubkey']);
                 fclose($pubkey_file_handler);
                 safe_exec("chmod 0664 " . escapeshellarg($pubkey_filename));
             }
             $dkimdomains .= $domain['domain'] . "\n";
             $dkimkeys .= "*@" . $domain['domain'] . ":" . $domain['domain'] . ":" . $privkey_filename . "\n";
         }
         $dkimdomains_filename = makeCorrectFile(Settings::Get('dkim.dkim_prefix') . '/' . Settings::Get('dkim.dkim_domains'));
         $dkimdomains_file_handler = fopen($dkimdomains_filename, "w");
         fwrite($dkimdomains_file_handler, $dkimdomains);
         fclose($dkimdomains_file_handler);
         $dkimkeys_filename = makeCorrectFile(Settings::Get('dkim.dkim_prefix') . '/' . Settings::Get('dkim.dkim_dkimkeys'));
         $dkimkeys_file_handler = fopen($dkimkeys_filename, "w");
         fwrite($dkimkeys_file_handler, $dkimkeys);
         fclose($dkimkeys_file_handler);
         safe_exec(escapeshellcmd(Settings::Get('dkim.dkimrestart_command')));
         fwrite($this->debugHandler, '  cron_tasks: Task4 - Dkim-milter reloaded' . "\n");
         $this->logger->logAction(CRON_ACTION, LOG_INFO, 'Dkim-milter reloaded');
     }
 }
开发者ID:nabeel-khan,项目名称:Froxlor,代码行数:57,代码来源:cron_tasks.inc.dns.10.bind.php

示例13: makeCorrectDir

$_mypath = makeCorrectDir(FROXLOR_INSTALL_DIR);
if ((int) Settings::Get('system.mod_fcgid') == 1 && (int) Settings::Get('system.mod_fcgid_ownvhost') == 1 || (int) Settings::Get('phpfpm.enabled') == 1 && (int) Settings::Get('phpfpm.enabled_ownvhost') == 1) {
    $user = Settings::Get('system.mod_fcgid_httpuser');
    $group = Settings::Get('system.mod_fcgid_httpgroup');
    if (Settings::Get('phpfpm.enabled') == 1) {
        $user = Settings::Get('phpfpm.vhost_httpuser');
        $group = Settings::Get('phpfpm.vhost_httpgroup');
    }
    // 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));
} else {
    // back to webserver permission
    $user = Settings::Get('system.httpuser');
    $group = Settings::Get('system.httpgroup');
    safe_exec('chown -R ' . $user . ':' . $group . ' ' . escapeshellarg($_mypath));
}
// Initialize logging
$cronlog = FroxlorLogger::getInstanceOf(array('loginname' => 'cronjob'));
fwrite($debugHandler, 'Logger has been included' . "\n");
if (hasUpdates($version) || hasDbUpdates($dbversion)) {
    if (Settings::Get('system.cron_allowautoupdate') == null || Settings::Get('system.cron_allowautoupdate') == 0) {
        /**
         * Do not proceed further if the Database version is not the same as the script version
         */
        fclose($debugHandler);
        unlink($lockfile);
        $errormessage = "Version of file doesn't match version of database. Exiting...\n\n";
        $errormessage .= "Possible reason: Froxlor update\n";
        $errormessage .= "Information: Current version in database: " . Settings::Get('panel.version') . " (DB: " . Settings::Get('panel.db_version') . ") - version of Froxlor files: " . $version . " (DB: " . $dbversion . ")\n";
        $errormessage .= "Solution: Please visit your Foxlor admin interface for further information.\n";
开发者ID:asemen,项目名称:Froxlor,代码行数:31,代码来源:cron_init.php

示例14: foreach

     foreach ($back as $backrow) {
         $webspaceusage = explode(' ', $backrow);
     }
     $webspaceusage = floatval($webspaceusage['0']);
     unset($back);
 } else {
     fwrite($debugHandler, 'documentroot ' . $row['documentroot'] . ' does not exist' . "\n");
 }
 /*
  * MailSpace-Usage
  */
 fwrite($debugHandler, 'calculating mailspace usage for ' . $row['loginname'] . "\n");
 $emailusage = 0;
 $maildir = makeCorrectDir($settings['system']['vmail_homedir'] . $row['loginname']);
 if (file_exists($maildir) && is_dir($maildir)) {
     $back = safe_exec('du -s ' . escapeshellarg($maildir) . '');
     foreach ($back as $backrow) {
         $emailusage = explode(' ', $backrow);
     }
     $emailusage = floatval($emailusage['0']);
     unset($back);
 } else {
     fwrite($debugHandler, 'maildir ' . $maildir . ' does not exist' . "\n");
 }
 /*
  * MySQLSpace-Usage
  */
 fwrite($debugHandler, 'calculating mysqlspace usage for ' . $row['loginname'] . "\n");
 $mysqlusage = 0;
 if (isset($mysqlusage_all[$row['customerid']])) {
     $mysqlusage = floatval($mysqlusage_all[$row['customerid']] / 1024);
开发者ID:markc,项目名称:syscp,代码行数:31,代码来源:cron_traffic.php

示例15: writeConfigs

 public function writeConfigs()
 {
     $this->logger->logAction(CRON_ACTION, LOG_INFO, "lighttpd::writeConfigs: rebuilding " . Settings::Get('system.apacheconf_vhost'));
     $vhostDir = new frxDirectory(Settings::Get('system.apacheconf_vhost'));
     if (!$vhostDir->isConfigDir()) {
         // Save one big file
         $vhosts_file = '';
         // sort by filename so the order is:
         // 1. main-domains
         // 2. subdomains as main-domains
         // 3. subdomains
         // (former #437) - #833 (the numbering is done in createLighttpdHosts())
         ksort($this->lighttpd_data);
         foreach ($this->lighttpd_data as $vhosts_filename => $vhost_content) {
             $vhosts_file .= $vhost_content . "\n\n";
         }
         $vhosts_filename = Settings::Get('system.apacheconf_vhost');
         // Apply header
         $vhosts_file = '# ' . basename($vhosts_filename) . "\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" . $vhosts_file;
         $vhosts_file_handler = fopen($vhosts_filename, 'w');
         fwrite($vhosts_file_handler, $vhosts_file);
         fclose($vhosts_file_handler);
     } else {
         if (!file_exists(Settings::Get('system.apacheconf_vhost'))) {
             $this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'lighttpd::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
             safe_exec('mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
         }
         // Write a single file for every vhost
         foreach ($this->lighttpd_data as $vhosts_filename => $vhosts_file) {
             $this->known_filenames[] = basename($vhosts_filename);
             // Apply header
             $vhosts_file = '# ' . basename($vhosts_filename) . "\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" . $vhosts_file;
             if (!empty($vhosts_filename)) {
                 $vhosts_file_handler = fopen($vhosts_filename, 'w');
                 fwrite($vhosts_file_handler, $vhosts_file);
                 fclose($vhosts_file_handler);
             }
         }
     }
     // Write the diroptions
     $htpasswdDir = new frxDirectory(Settings::Get('system.apacheconf_htpasswddir'));
     if ($htpasswdDir->isConfigDir()) {
         foreach ($this->needed_htpasswds as $key => $data) {
             if (!is_dir(Settings::Get('system.apacheconf_htpasswddir'))) {
                 mkdir(makeCorrectDir(Settings::Get('system.apacheconf_htpasswddir')));
             }
             $filename = makeCorrectFile(Settings::Get('system.apacheconf_htpasswddir') . '/' . $key);
             $htpasswd_handler = fopen($filename, 'w');
             fwrite($htpasswd_handler, $data);
             fclose($htpasswd_handler);
         }
     }
 }
开发者ID:nachtgeist,项目名称:Froxlor,代码行数:53,代码来源:cron_tasks.inc.http.20.lighttpd.php


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