mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 00:48:25 +00:00
Adding method to generate a random key for CAKE_SESSION_STRING when using bake
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4643 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
a5aa05da83
commit
77d789c0ac
1 changed files with 22 additions and 1 deletions
|
@ -2088,6 +2088,11 @@ class Bake {
|
|||
$this->hr();
|
||||
$this->__defaultHome($projectPath, $appName);
|
||||
$this->stdout('Welcome page created');
|
||||
if($this->__generateHash() === true ){
|
||||
$this->stdout('Random hash key created for CAKE_SESSION_STRING');
|
||||
} else {
|
||||
$this->stdout('Unable to generate random hash for CAKE_SESSION_STRING, please change this yourself in ' . CONFIGS . 'core.php');
|
||||
}
|
||||
if(chmodr($projectPath.DS.'tmp', 0777) === false) {
|
||||
$this->stdout('Could not set permissions on '. $projectPath.DS.'tmp'.DS.'*');
|
||||
$this->stdout('You must manually check that these directories can be wrote to by the server');
|
||||
|
@ -2111,7 +2116,7 @@ class Bake {
|
|||
function __copydirr($fromDir, $toDir, $chmod = 0755, $verbose = false) {
|
||||
$errors=array();
|
||||
$messages=array();
|
||||
|
||||
|
||||
uses('folder');
|
||||
$folder = new Folder($toDir, true, 0755);
|
||||
|
||||
|
@ -2177,6 +2182,22 @@ class Bake {
|
|||
if (preg_match('%([/\\t\\x20]*define\\(\'CAKE_ADMIN\',[\\t\\x20\'a-z]*\\);)%', $file, $match)) {
|
||||
$result = str_replace($match[0], 'define(\'CAKE_ADMIN\', \''.$name.'\');', $file);
|
||||
|
||||
if(file_put_contents(CONFIGS.'core.php', $result)){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function __generateHash(){
|
||||
$file = file_get_contents(CONFIGS.'core.php');
|
||||
if (preg_match('/([\\t\\x20]*define\\(\\\'CAKE_SESSION_STRING\\\',[\\t\\x20\'A-z0-9]*\\);)/', $file, $match)) {
|
||||
uses('Security');
|
||||
$string = Security::generateAuthKey();
|
||||
$result = str_replace($match[0], 'define(\'CAKE_SESSION_STRING\', \''.$string.'\');', $file);
|
||||
|
||||
if(file_put_contents(CONFIGS.'core.php', $result)){
|
||||
return true;
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue