CC-5802: Upgrade application.ini file

This commit is contained in:
drigato 2014-04-24 10:22:52 -04:00
parent 2f8461b2a6
commit fcd8ea8ba5
1 changed files with 29 additions and 8 deletions

View File

@ -38,15 +38,36 @@ class UpgradeController extends Zend_Controller_Action
//update application.ini //update application.ini
$newLines = "resources.frontController.moduleDirectory = APPLICATION_PATH '/modules'\n". $newLines = "resources.frontController.moduleDirectory = APPLICATION_PATH '/modules'\n".
"resources.frontController.plugins.putHandler = 'Zend_Controller_Plugin_PutHandler'". "resources.frontController.plugins.putHandler = 'Zend_Controller_Plugin_PutHandler'\n".
";load everything in the modules directory including models". ";load everything in the modules directory including models\n".
"resources.modules[] = ''"; "resources.modules[] = ''\n";
$file = fopen($iniFile, "r+"); $currentIniFile = file_get_contents($iniFile);
//set pointer to line after '[production]' - kind of hacky but will do for now
fseek($file, -1, SEEK_CUR); /* We want to add the new lines immediately after the first line, '[production]'
fwrite($file, $newLines); * We read the first line into $beginning, and the rest of the file into $end.
fclose($file); * Then overwrite the current application.ini file with $beginning, $newLines, and $end
*/
$lines = explode("\n", $currentIniFile);
$beginning = implode("\n", array_slice($lines, 0,1));
//check that first line is '[production]'
if ($beginning != '[production]') {
$this->getResponse()
->setHttpResponseCode(400)
->appendBody('Upgrade to Airtime 2.5.3 FAILED. Could not upgrade application.ini');
return;
}
$end = implode("\n", array_slice($lines, 1));
if (!is_writeable($iniFile)) {
$this->getResponse()
->setHttpResponseCode(400)
->appendBody('Upgrade to Airtime 2.5.3 FAILED. Could not upgrade application.ini');
return;
}
$file = new SplFileObject($iniFile, "w");
$file->fwrite($beginning."\n".$newLines.$end);
$this->getResponse() $this->getResponse()
->setHttpResponseCode(200) ->setHttpResponseCode(200)