mirror of
https://github.com/icecoder/ICEcoder.git
synced 2026-03-03 07:13:59 +01:00
Check old version is writeable before update
Checks all ICEcoder files are writeable and therefore moveable, before proceeding with the update. If it files any that aren't, it will display a message, list them and die with a link back to ICEcoder. Also ignoring .git dir
This commit is contained in:
@@ -14,6 +14,33 @@ define('PATH', '../tmp/oldVersion/');
|
||||
$updateDone = false;
|
||||
|
||||
function startUpdate() {
|
||||
// First, check old version is entirely moveable
|
||||
$source = "../";
|
||||
$cantMoveArray = array();
|
||||
echo 'Checking we can entirely move old ICEcoder version...<br>';
|
||||
foreach ($iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS),RecursiveIteratorIterator::SELF_FIRST) as $item) {
|
||||
if (strpos($source.DIRECTORY_SEPARATOR.$iterator->getSubPathName(),"oldVersion")==false) {
|
||||
// Don't move plugins or .git away
|
||||
$testPath = $source.DIRECTORY_SEPARATOR.$iterator->getSubPathName();
|
||||
$testPath = str_replace("\\","/",$testPath);
|
||||
if (strpos($testPath,"/plugins/")==false && strpos($testPath,"/.git/")==false) {
|
||||
if (!is_writeable($item)) {
|
||||
array_push($cantMoveArray,substr($item,count($source)+2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count($cantMoveArray) > 0) {
|
||||
echo '<br>Sorry, there are dirs/files that cannot be moved. Please set write permissions on them so ICEcoder may move the old version, to make way for the new.<br><br>You can reload this page after making perms changes to check the list again.<br><br>';
|
||||
for ($i=0; $i<count($cantMoveArray); $i++) {
|
||||
echo $cantMoveArray[$i]."<br>";
|
||||
}
|
||||
die('<br><a href="'.$source.'" style="color: #fff"><< Back to ICEcoder</a>');
|
||||
}
|
||||
renameOldVersion();
|
||||
}
|
||||
|
||||
function renameOldVersion() {
|
||||
if (is_dir(PATH)) {
|
||||
echo 'Postfixing oldVersion dir with a timestamp...<br>';
|
||||
rename(PATH,trim(PATH,"/")."-".time());
|
||||
@@ -37,10 +64,10 @@ function copyOldVersion() {
|
||||
echo 'Moving current ICEcoder files...<br>';
|
||||
foreach ($iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS),RecursiveIteratorIterator::SELF_FIRST) as $item) {
|
||||
if (strpos($source.DIRECTORY_SEPARATOR.$iterator->getSubPathName(),"oldVersion")==false) {
|
||||
// Don't move plugins away
|
||||
// Don't move plugins or .git away
|
||||
$testPath = $source.DIRECTORY_SEPARATOR.$iterator->getSubPathName();
|
||||
$testPath = str_replace("\\","/",$testPath);
|
||||
if (strpos($testPath,"/plugins/")==false) {
|
||||
if (strpos($testPath,"/plugins/")==false && strpos($testPath,"/.git/")==false) {
|
||||
if ($item->isDir()) {
|
||||
mkdir($dest.DIRECTORY_SEPARATOR.$iterator->getSubPathName(), 0755);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user