Example #1
0
function copyCxFilesToRoot($src, $dst)
{
    static $copiedCxFilesIndex = 0;
    $src = str_replace('\\', '/', $src);
    $dst = str_replace('\\', '/', $dst);
    $dir = opendir($src);
    $arrCurrentFolderStructure = array();
    while ($file = readdir($dir)) {
        if (!in_array($file, array('.', '..'))) {
            $arrCurrentFolderStructure[] = $file;
        }
    }
    sort($arrCurrentFolderStructure);
    if (!isset($_SESSION['contrexx_update']['copiedCxFilesTotal'])) {
        $_SESSION['contrexx_update']['copiedCxFilesTotal'] = 0;
    }
    foreach ($arrCurrentFolderStructure as $file) {
        if (!checkMemoryLimit() || !checkTimeoutLimit()) {
            $_SESSION['contrexx_update']['copiedCxFilesIndex'] = $copiedCxFilesIndex;
            return 'timeout';
        }
        $srcPath = $src . '/' . $file;
        $dstPath = $dst . '/' . $file;
        if (is_dir($srcPath)) {
            \Cx\Lib\FileSystem\FileSystem::make_folder($dstPath);
            $status = copyCxFilesToRoot($srcPath, $dstPath);
            if ($status !== true) {
                return $status;
            }
        } else {
            $copiedCxFilesIndex++;
            if (isset($_SESSION['contrexx_update']['copiedCxFilesIndex']) && $copiedCxFilesIndex <= $_SESSION['contrexx_update']['copiedCxFilesIndex']) {
                continue;
            }
            $_SESSION['contrexx_update']['copiedCxFilesTotal'] = $_SESSION['contrexx_update']['copiedCxFilesTotal'] + 1;
            try {
                // rename the file if its exists on customizing
                if (!renameCustomizingFile($dstPath)) {
                    return false;
                }
                if (!verifyMd5SumOfFile($dstPath, $srcPath)) {
                    if (!backupModifiedFile($dstPath)) {
                        return false;
                    }
                }
                $objFile = new \Cx\Lib\FileSystem\File($srcPath);
                $objFile->copy($dstPath, true);
            } catch (\Exception $e) {
                $copiedCxFilesIndex--;
                $_SESSION['contrexx_update']['copiedCxFilesIndex'] = $copiedCxFilesIndex;
                $_SESSION['contrexx_update']['copiedCxFilesTotal'] = $_SESSION['contrexx_update']['copiedCxFilesTotal'] - 1;
                setUpdateMsg('Folgende Datei konnte nicht installiert werden:<br />' . $dstPath);
                setUpdateMsg('Fehler: ' . $e->getMessage());
                setUpdateMsg('<br />Häufigste Ursache dieses Problems ist, dass zur Ausführung dieses Vorgangs die benötigten Schreibrechte nicht vorhanden sind. Prüfen Sie daher, ob die FTP-Konfiguration in der Datei <strong>config/configuration.php</strong> korrekt eingerichtet ist.');
                return false;
            }
        }
    }
    closedir($dir);
    return true;
}
Example #2
0
        if ($result !== false) {
            while (!$result->EOF) {
                \Cx\Lib\UpdateUtil::sql("INSERT IGNORE INTO `" . DBPREFIX . "access_group_static_ids` (`access_id`, `group_id`)\n                                            VALUES (143, " . intval($result->fields['group_id']) . ")");
                $result->MoveNext();
            }
        }
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
}
if (file_exists(ASCMS_DOCUMENT_ROOT . ASCMS_BACKEND_PATH . '/index.php')) {
    // move cadmin index.php if its customized
    if (!loadMd5SumOfOriginalCxFiles()) {
        return false;
    }
    if (!verifyMd5SumOfFile(ASCMS_DOCUMENT_ROOT . ASCMS_BACKEND_PATH . '/index.php', '', false)) {
        \DBG::msg('...and it\'s customized, so let\'s move it to customizing directory');
        // changes, backup modified file
        if (!backupModifiedFile(ASCMS_DOCUMENT_ROOT . ASCMS_BACKEND_PATH . '/index.php')) {
            setUpdateMsg('Die Datei \'' . ASCMS_DOCUMENT_ROOT . ASCMS_BACKEND_PATH . '/index.php\' konnte nicht kopiert werden.');
            return false;
        }
    } else {
        \DBG::msg('...but it\'s not customized');
    }
    // no non-backupped changes, can delete
    try {
        \DBG::msg('So let\'s remove it...');
        $cadminIndex = new \Cx\Lib\FileSystem\File(ASCMS_DOCUMENT_ROOT . ASCMS_BACKEND_PATH . '/index.php');
        $cadminIndex->delete();
    } catch (\Cx\Lib\FileSystem\FileSystemException $e) {