本文整理汇总了PHP中owa_coreAPI::secureRandomString方法的典型用法代码示例。如果您正苦于以下问题:PHP owa_coreAPI::secureRandomString方法的具体用法?PHP owa_coreAPI::secureRandomString怎么用?PHP owa_coreAPI::secureRandomString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类owa_coreAPI
的用法示例。
在下文中一共展示了owa_coreAPI::secureRandomString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: up
function up($force = false)
{
//$handle = fopen(OWA_DIR . 'owa-config.php', 'r+');
$c = file_get_contents(OWA_DIR . 'owa-config.php');
$ret = copy(OWA_DIR . 'owa-config.php', OWA_DIR . 'owa-config.php.backup.' . time());
if ($ret === false) {
$this->e->notice('A backup of your owa-config.php could not be created. Check permissions to ensure your main OWA directory is writable.');
return false;
}
if ($c) {
$n0 = "\n/**\n * AUTHENTICATION KEYS AND SALTS\n * \n * Change these to different unique phrases.\n */" . PHP_EOL . PHP_EOL;
$n1 = "define('OWA_NONCE_KEY', '" . owa_coreAPI::secureRandomString(64) . "');" . PHP_EOL;
$n2 = "define('OWA_NONCE_SALT', '" . owa_coreAPI::secureRandomString(64) . "');" . PHP_EOL;
$n3 = "define('OWA_AUTH_KEY', '" . owa_coreAPI::secureRandomString(64) . "');" . PHP_EOL;
$n4 = "define('OWA_AUTH_SALT', '" . owa_coreAPI::secureRandomString(64) . "');" . PHP_EOL . PHP_EOL;
$ne = "?>";
$value = $n0 . $n1 . $n2 . $n3 . $n4 . $ne;
//fseek($handle, -1, SEEK_END);
//$ret = fwrite($handle, $value);
//fclose($handle);
$c = str_replace('?>', $value, $c);
$ret = file_put_contents(OWA_DIR . 'owa-config.php', $c);
if ($ret === false) {
$this->e->notice('owa-config.php could not be written to. Check permissions to ensure this file is writable.');
return false;
}
$this->e->notice('Auth keys added to owa-config.php.');
return true;
} else {
$this->e->notice('owa-config.php could not be read. check permissions to ensure this file is readable.');
return false;
}
}
示例2: createConfigFile
/**
* Writes the config file based on the default config file - but with the given database credentials
*
* @param array $config_values with the database setting keys
*/
public function createConfigFile($config_values)
{
if (file_exists(OWA_DIR . 'owa-config.php')) {
owa_coreAPI::error("Your config file already exists. If you need to change your configuration, edit that file at: " . OWA_DIR . 'owa-config.php');
require_once OWA_DIR . 'owa-config.php';
return true;
}
if (!file_exists(OWA_DIR . 'owa-config-dist.php')) {
$errorMsg = "We can't find the configuration file template. Are you sure you installed OWA's files correctly? Exiting.";
owa_coreAPI::error($errorMsg);
throw new Exception($errorMsg);
}
$configFileTemplate = file(OWA_DIR . 'owa-config-dist.php');
owa_coreAPI::debug('found sample config file.');
$handle = fopen(OWA_DIR . 'owa-config.php', 'w');
foreach ($configFileTemplate as $line_num => $line) {
switch (substr($line, 0, 20)) {
case "define('OWA_DB_TYPE'":
fwrite($handle, str_replace("yourdbtypegoeshere", $config_values['db_type'], $line));
break;
case "define('OWA_DB_NAME'":
fwrite($handle, str_replace("yourdbnamegoeshere", $config_values['db_name'], $line));
break;
case "define('OWA_DB_USER'":
fwrite($handle, str_replace("yourdbusergoeshere", $config_values['db_user'], $line));
break;
case "define('OWA_DB_PASSW":
fwrite($handle, str_replace("yourdbpasswordgoeshere", $config_values['db_password'], $line));
break;
case "define('OWA_DB_HOST'":
fwrite($handle, str_replace("yourdbhostgoeshere", $config_values['db_host'], $line));
break;
case "define('OWA_PUBLIC_U":
fwrite($handle, str_replace("http://domain/path/to/owa/", $config_values['public_url'], $line));
break;
case "define('OWA_NONCE_KE":
fwrite($handle, str_replace("yournoncekeygoeshere", owa_coreAPI::secureRandomString(64), $line));
break;
case "define('OWA_NONCE_SA":
fwrite($handle, str_replace("yournoncesaltgoeshere", owa_coreAPI::secureRandomString(64), $line));
break;
case "define('OWA_AUTH_KEY":
fwrite($handle, str_replace("yourauthkeygoeshere", owa_coreAPI::secureRandomString(64), $line));
break;
case "define('OWA_AUTH_SAL":
fwrite($handle, str_replace("yourauthsaltgoeshere", owa_coreAPI::secureRandomString(64), $line));
break;
default:
fwrite($handle, $line);
}
}
fclose($handle);
chmod(OWA_DIR . 'owa-config.php', 0750);
owa_coreAPI::debug('Config file created');
require_once OWA_DIR . 'owa-config.php';
return true;
}