本文整理汇总了PHP中Bootstrap::getSettings方法的典型用法代码示例。如果您正苦于以下问题:PHP Bootstrap::getSettings方法的具体用法?PHP Bootstrap::getSettings怎么用?PHP Bootstrap::getSettings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bootstrap
的用法示例。
在下文中一共展示了Bootstrap::getSettings方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createSystem
function createSystem()
{
global $settings;
global $_testInstall_Ok;
try {
/*
* The settings system is used to create a lot of output,
* we swallow it all
*/
ob_start();
/*
* Get the schema version and other constants
*/
require_once "lib/Bootstrap.php";
$bootstrap = new Bootstrap();
/*
* Now create the database
*/
$dbsettings = $_SESSION['spotsettings']['db'];
$dbCon = dbeng_abs::getDbFactory($dbsettings['engine']);
$dbCon->connect($dbsettings['host'], $dbsettings['user'], $dbsettings['pass'], $dbsettings['dbname']);
$daoFactory = Dao_Factory::getDAOFactory($dbsettings['engine']);
$daoFactory->setConnection($dbCon);
/*
* The database must exist before we can get the Service_Settings_Base instance
*/
$dbStruct = SpotStruct_abs::factory($dbsettings['engine'], $daoFactory->getConnection());
$dbStruct->updateSchema();
$spotSettings = $bootstrap->getSettings($daoFactory, false);
$svcUpgradeBase = new Services_Upgrade_Base($daoFactory, $spotSettings, $dbsettings['engine']);
/*
* Create all the different settings (only the default) ones
*/
$svcUpgradeBase->settings();
/*
* Create the users
*/
$svcUpgradeBase->users();
/*
* print all the output as HTML comment for debugging
*/
$dbCreateOutput = ob_get_contents();
ob_end_clean();
/*
* Now it is time to do something with
* the information the user has given to us
*/
/*
* Update the NNTP settings in the databas
*/
$spotSettings->set('nntp_nzb', $_SESSION['spotsettings']['nntp']['nzb']);
$spotSettings->set('nntp_hdr', $_SESSION['spotsettings']['nntp']['hdr']);
$spotSettings->set('nntp_post', $_SESSION['spotsettings']['nntp']['post']);
/*
* Create the given user
*/
$svcUserRecord = new Services_User_Record($daoFactory, $spotSettings);
$spotUser = $_SESSION['spotsettings']['adminuser'];
/*
* and actually add the user
*/
$spotUser['userid'] = $svcUserRecord->createUserRecord($spotUser)->getData('userid');
/*
* When the new user was created a random password was assigned,
* so now have to set the supplied password
*/
$svcUserRecord->setUserPassword($spotUser);
# Change the administrators' account password to that of this created user
$adminUser = $svcUserRecord->getUser(SPOTWEB_ADMIN_USERID);
$adminUser['newpassword1'] = $spotUser['newpassword1'];
$svcUserRecord->setUserPassword($adminUser);
# update the settings with our system type and our admin id
$spotSettings->set('custom_admin_userid', $spotUser['userid']);
$spotSettings->set('systemtype', $spotUser['systemtype']);
# Set the system type
$svcUpgradeBase->resetSystemType($spotUser['systemtype']);
/*
* Create the necessary database connection information
*/
$dbConnectionString = '';
switch ($_SESSION['spotsettings']['db']['engine']) {
case 'pdo_mysql':
$dbConnectionString .= "\$dbsettings['engine'] = 'pdo_mysql';" . PHP_EOL;
$dbConnectionString .= "\$dbsettings['host'] = '" . $_SESSION['spotsettings']['db']['host'] . "';" . PHP_EOL;
$dbConnectionString .= "\$dbsettings['dbname'] = '" . $_SESSION['spotsettings']['db']['dbname'] . "';" . PHP_EOL;
$dbConnectionString .= "\$dbsettings['user'] = '" . $_SESSION['spotsettings']['db']['user'] . "';" . PHP_EOL;
$dbConnectionString .= "\$dbsettings['pass'] = '" . $_SESSION['spotsettings']['db']['pass'] . "';" . PHP_EOL;
break;
# mysql
# mysql
case 'pdo_pgsql':
$dbConnectionString .= "\$dbsettings['engine'] = 'pdo_pgsql';" . PHP_EOL;
$dbConnectionString .= "\$dbsettings['host'] = '" . $_SESSION['spotsettings']['db']['host'] . "';" . PHP_EOL;
$dbConnectionString .= "\$dbsettings['dbname'] = '" . $_SESSION['spotsettings']['db']['dbname'] . "';" . PHP_EOL;
$dbConnectionString .= "\$dbsettings['user'] = '" . $_SESSION['spotsettings']['db']['user'] . "';" . PHP_EOL;
$dbConnectionString .= "\$dbsettings['pass'] = '" . $_SESSION['spotsettings']['db']['pass'] . "';" . PHP_EOL;
break;
# pdo_pgsql
}
# switch
//.........这里部分代码省略.........
示例2: chdir
* working directory to a directory the script is in
*/
if (@(!file_exists(getcwd() . '/' . basename($argv[0])))) {
chdir(dirname(__FILE__));
}
# if
require_once "lib/SpotClassAutoload.php";
SpotClassAutoload::register();
require_once "lib/Bootstrap.php";
/*
* Create a DAO factory. We cannot use the bootstrapper here,
* because it validates for a valid settings etc. version.
*/
$bootstrap = new Bootstrap();
$daoFactory = $bootstrap->getDaoFactory();
$settings = $bootstrap->getSettings($daoFactory, true);
$dbSettings = $bootstrap->getDbSettings();
/*
* Try to create the directory, we hardcode it here because
* it cannot be made configurable in the database anyway
* and this is just the lazy way out, really
*/
$daoFactory->setCachePath('./cache/');
$cacheDao = $daoFactory->getCacheDao();
if (!is_dir('./cache')) {
mkdir('./cache', 0777);
}
# if
/*
* Now try to get all current cache items
*/
示例3: array
/*
* Make sure we are not run from the server, an db upgrade can take too much time and
* will easily be aborted by either a database, apache or browser timeout
*/
SpotCommandline::initialize(array('reset-groupmembership', 'reset-securitygroups', 'reset-filters'), array('reset-groupmembership' => false, 'reset-securitygroups' => false, 'reset-filters' => false, 'set-systemtype' => false, 'reset-password' => false, 'mass-userprefchange' => false));
if (!SpotCommandline::isCommandline()) {
die("upgrade-db.php can only be run from the console, it cannot be run from the web browser");
}
# if
/*
* Create a DAO factory. We cannot use the bootstrapper here,
* because it validates for a valid settings etc. version.
*/
$bootstrap = new Bootstrap();
$daoFactory = $bootstrap->getDaoFactory();
$settings = $bootstrap->getSettings($daoFactory, false);
$dbSettings = $bootstrap->getDbSettings();
/*
* And actually start updating or creating the schema and settings
*/
echo "Updating schema..(" . $dbSettings['engine'] . ")" . PHP_EOL;
$svcUpgradeBase = new Services_Upgrade_Base($daoFactory, $settings, $dbSettings['engine']);
$svcUpgradeBase->database();
echo "Schema update done" . PHP_EOL;
echo "Updating settings" . PHP_EOL;
$svcUpgradeBase->settings();
$svcUpgradeBase->usenetState();
echo "Settings update done" . PHP_EOL;
$svcUpgradeBase->users($settings);
echo "Updating users" . PHP_EOL;
echo "Users' update done" . PHP_EOL;