本文整理汇总了PHP中ACL::createRandomKey方法的典型用法代码示例。如果您正苦于以下问题:PHP ACL::createRandomKey方法的具体用法?PHP ACL::createRandomKey怎么用?PHP ACL::createRandomKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACL
的用法示例。
在下文中一共展示了ACL::createRandomKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createSConfigurationFile
public function createSConfigurationFile($params)
{
try {
if (file_exists($conf = 'sites/conf.example.php')) {
if (($params->AESkey = ACL::createRandomKey()) !== false) {
$buffer = file_get_contents($conf);
$search = ['#host#', '#user#', '#pass#', '#db#', '#port#', '#key#', '#lang#', '#theme#', '#timezone#', '#sitename#', '#hl7Port#'];
$replace = [$params->dbHost, $params->dbUser, $params->dbPass, $params->dbName, $params->dbPort, $params->AESkey, $params->lang, $params->theme, $params->timezone, $params->siteId, 9100];
$newConf = str_replace($search, $replace, $buffer);
$siteDir = "sites/{$params->siteId}";
$conf_file = "{$siteDir}/conf.php";
$handle = fopen($conf_file, 'w');
fwrite($handle, $newConf);
fclose($handle);
chmod($conf_file, 0644);
if (file_exists($conf_file)) {
return ['success' => true, 'AESkey' => $params->AESkey];
} else {
throw new Exception("Unable to create {$siteDir}/conf.php file");
}
} else {
throw new Exception('Unable to Generate AES 32 bit key');
}
} else {
throw new Exception('Unable to Find sites/conf.example.php');
}
} catch (Exception $Error) {
return ['success' => false, 'error' => $Error->getMessage()];
}
}
示例2: createSConfigurationFile
public function createSConfigurationFile($params)
{
if (file_exists($conf = 'sites/conf.example.php')) {
if (($params->AESkey = ACL::createRandomKey()) !== false) {
$buffer = file_get_contents($conf);
$search = array('%host%', '%user%', '%pass%', '%db%', '%port%', '%key%', '%lang%', '%theme%', '%timezone%', '%sitename%');
$replace = array($params->dbHost, $params->dbUser, $params->dbPass, $params->dbName, $params->dbPort, $params->AESkey, $params->lang, $params->theme, $params->timezone, $params->siteId);
$newConf = str_replace($search, $replace, $buffer);
$siteDir = "sites/{$params->siteId}";
$conf_file = "{$siteDir}/conf.php";
$handle = fopen($conf_file, 'w');
fwrite($handle, $newConf);
fclose($handle);
chmod($conf_file, 0644);
if (file_exists($conf_file)) {
return array('success' => true, 'AESkey' => $params->AESkey);
} else {
return array('success' => false, 'error' => "Unable to create {$siteDir}/conf.php file");
}
} else {
return array('success' => false, 'error' => 'Unable to Generate AES 32 bit key');
}
} else {
return array('success' => false, 'error' => 'Unable to Find sites/conf.example.php');
}
}