當前位置: 首頁>>代碼示例>>PHP>>正文


PHP moodle_database::export_dbconfig方法代碼示例

本文整理匯總了PHP中moodle_database::export_dbconfig方法的典型用法代碼示例。如果您正苦於以下問題:PHP moodle_database::export_dbconfig方法的具體用法?PHP moodle_database::export_dbconfig怎麽用?PHP moodle_database::export_dbconfig使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在moodle_database的用法示例。


在下文中一共展示了moodle_database::export_dbconfig方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: install_generate_configphp

/**
 * Returns content of config.php file.
 *
 * Uses PHP_EOL for generating proper end of lines for the given platform.
 *
 * @param moodle_database $database database instance
 * @param object $cfg copy of $CFG
 * @return string
 */
function install_generate_configphp($database, $cfg)
{
    $configphp = '<?php  // Moodle configuration file' . PHP_EOL . PHP_EOL;
    $configphp .= 'unset($CFG);' . PHP_EOL;
    $configphp .= 'global $CFG;' . PHP_EOL;
    $configphp .= '$CFG = new stdClass();' . PHP_EOL . PHP_EOL;
    // prevent PHP5 strict warnings
    $dbconfig = $database->export_dbconfig();
    foreach ($dbconfig as $key => $value) {
        $key = str_pad($key, 9);
        $configphp .= '$CFG->' . $key . ' = ' . var_export($value, true) . ';' . PHP_EOL;
    }
    $configphp .= PHP_EOL;
    $configphp .= '$CFG->wwwroot   = ' . var_export($cfg->wwwroot, true) . ';' . PHP_EOL;
    $configphp .= '$CFG->dataroot  = ' . var_export($cfg->dataroot, true) . ';' . PHP_EOL;
    $configphp .= '$CFG->admin     = ' . var_export($cfg->admin, true) . ';' . PHP_EOL . PHP_EOL;
    if (empty($cfg->directorypermissions)) {
        $chmod = '02777';
    } else {
        $chmod = '0' . decoct($cfg->directorypermissions);
    }
    $configphp .= '$CFG->directorypermissions = ' . $chmod . ';' . PHP_EOL . PHP_EOL;
    $configphp .= '$CFG->passwordsaltmain = ' . var_export(complex_random_string(), true) . ';' . PHP_EOL . PHP_EOL;
    $configphp .= 'require_once(dirname(__FILE__) . \'/lib/setup.php\');' . PHP_EOL . PHP_EOL;
    $configphp .= '// There is no php closing tag in this file,' . PHP_EOL;
    $configphp .= '// it is intentional because it prevents trailing whitespace problems!' . PHP_EOL;
    return $configphp;
}
開發者ID:JP-Git,項目名稱:moodle,代碼行數:37,代碼來源:installlib.php

示例2: install_generate_configphp

/**
 * Returns content of config.php file.
 * @param moodle_database $database database instance
 * @param object $cfg copy of $CFG
 * @param bool $userealpath allows symbolic links in dirroot
 * @return string
 */
function install_generate_configphp($database, $cfg, $userealpath = false)
{
    $configphp = '<?php  // Moodle Configuration File ' . "\r\n\r\n";
    $configphp .= 'unset($CFG);' . "\r\n";
    $configphp .= '$CFG = new stdClass();' . "\r\n\r\n";
    // prevent PHP5 strict warnings
    $dbconfig = $database->export_dbconfig();
    foreach ($dbconfig as $key => $value) {
        $key = str_pad($key, 9);
        $configphp .= '$CFG->' . $key . ' = ' . var_export($value, true) . ";\r\n";
    }
    $configphp .= "\r\n";
    $configphp .= '$CFG->wwwroot   = ' . var_export($cfg->wwwroot, true) . ";\r\n";
    if ($userealpath) {
        $dirroot = str_replace('\\', '/', $cfg->dirroot);
        // win32 fix
        $dirroot = rtrim($dirroot, '/');
        // no trailing /
        $configphp .= '$CFG->dirroot   = realpath(' . var_export($dirroot, true) . ");\r\n";
        // fix for sym links
    } else {
        $dirroot = str_replace('\\', '/', $cfg->dirroot);
        // win32 fix
        $dirroot = rtrim($dirroot, '/');
        // no trailing /
        $configphp .= '$CFG->dirroot   = ' . var_export($dirroot, true) . ";\r\n";
    }
    $dataroot = str_replace('\\', '/', $cfg->dataroot);
    // win32 fix
    $dataroot = rtrim($dataroot, '/');
    // no trailing /
    $configphp .= '$CFG->dataroot  = ' . var_export($dataroot, true) . ";\r\n";
    $configphp .= '$CFG->admin     = ' . var_export($cfg->admin, true) . ";\r\n\r\n";
    $configphp .= '$CFG->directorypermissions = 00777;  // try 02777 on a server in Safe Mode' . "\r\n";
    $configphp .= "\r\n";
    $configphp .= 'require_once("$CFG->dirroot/lib/setup.php");' . "\r\n\r\n";
    $configphp .= '// There is no php closing tag in this file,' . "\r\n";
    $configphp .= '// it is intentional because it prevents trailing whitespace problems!' . "\r\n";
    return $configphp;
}
開發者ID:ajv,項目名稱:Offline-Caching,代碼行數:47,代碼來源:installlib.php


注:本文中的moodle_database::export_dbconfig方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。