Esempio n. 1
0
/**
 *  The last installer step is shown:
 *  - after STEP_WRITECONFIG if ishidden is enabled
 *  - in the "else" statement above this function :)
 */
function TheLastInstallerStep()
{
    global $page;
    global $mask;
    global $steps;
    global $config;
    // Only show "outro" message if enabled
    if ($steps[STEP_FINISHED]['enabled']) {
        // Installation is done!
        $page->MainTitle($steps[STEP_FINISHED]['title'], 'cake');
        $page->Paragraph($mask->GetFinishedMessage() . '<br />&nbsp;');
    }
    // If the installer will be ignored after installation
    // then do not offer the user to remove files or reset
    // the installation - Installer will be ignored either way
    if ($config['ignore_installer_when_done']) {
        $page->FormStart();
        $page->FormSubmit('Finished!');
        $page->FormClose();
        $page->ShowPage(STEP_FINISHED, true, false);
    }
    // Only continue if self destruction is enabled
    if ($config['allow_self_destruction']) {
        // If the user requested all installer files should be deleted,
        // or the installer should automatically self destruct
        if ($config['automatically_self_destruct'] || isset($_REQUEST['doneaction']) && $_REQUEST['doneaction'] == 'selfdestruct') {
            // Only include destroyer functions when they are needed
            require 'assets' . DIRECTORY_SEPARATOR . 'helper.destroyer.php';
            /* Since the PHP files have ALL been "included", their
             *  existance does not matter anymore. The rest of the 
             *  script will run normally even though all files have
             *  been deleted. */
            // Delete all files configured by config and display results
            $deletionStatus = DeleteYourself();
            if (is_array($deletionStatus)) {
                $dirs = $deletionStatus['dirs'];
                $files = $deletionStatus['files'];
                // Removing files
                if ($files['success'] == $files['total'] && $files['failed'] == 0) {
                    $page->SuccessBox('All Installer files where removed successfully!');
                } else {
                    if ($files['success'] == 0 && $files['total'] > 0) {
                        $page->WarningBox('Unable to remove Installer files, you have to remove them manually');
                    } else {
                        $page->ErrorBox('Error occur removing Installer files, <b>' . $files['failed'] . '</b> failed to be removed and need manual removal.');
                    }
                }
                // Removing directories
                if ($dirs['success'] == $dirs['total'] && $dirs['failed'] == 0) {
                    $page->SuccessBox('All Installer directories where removed successfully!');
                } else {
                    if ($dirs['success'] == 0) {
                        $page->WarningBox('Unable to remove Installer directories, you have to remove them manually');
                    } else {
                        $page->ErrorBox('Error occur removing Installer directories, <b>' . $dirs['failed'] . '</b> failed to be removed and need manual removal.');
                    }
                }
                $page->FormStart();
                $page->FormSubmit('Finished!');
                $page->FormClose();
                $page->ShowPage(STEP_FINISHED, true, false);
            }
        }
    }
    /*
     *  Deletion has not been initiated, so show options on what to do depending
     *  on what is configured in the config
     */
    // Should the current config be deleted and installation reset?
    if ($config['allow_overriding_oldconfig']) {
        $page->SubTitle('Start all over', 'remconf');
        $page->Paragraph('If you are not happy with the installation, you can make the Installer remove ' . 'current configuration and start all over again. <b>WARNING:</b> Any database ' . 'change cannot be undone! You have to undo the database installation manually.');
        # NOTE!
        # this done-action is processed in [helper.sessions.php]!
        $page->FormStart(array('doneaction' => 'removeold'));
        $page->FormSubmit('Remove current configuration and start over');
        $page->FormClose();
    }
    // If self-destruction is enabled but does not start it automatically
    if ($config['allow_self_destruction']) {
        $page->SubTitle('Delete Installer', 'exit');
        $page->Paragraph('Installation is completed but the Installer is preventing the installed system to ' . 'launch. You can make the Installer remove itself from the webserver if you wish ' . 'not to remove them yourself.');
        $page->FormStart(array('doneaction' => 'selfdestruct'));
        $page->FormSubmit('Delete all Installer files from the Webserver');
        $page->FormClose();
    }
    // If the installer is unable to do anything after installation!
    if (!$config['allow_overriding_oldconfig'] && !$config['allow_self_destruction']) {
        $page->WarningBox('You have to manually remove the Installer folder: <b>' . FixPath(INST_BASEDIR . INST_RUNFOLDER) . '</b> in order to view the installed system');
    }
    $page->ShowPage(STEP_FINISHED, true, false);
}
/**
 *  Delete the final output config and return a boolean
 *  notifing if it was successful or not
 */
function DeleteFinalOutputConfig()
{
    global $steps;
    // Get the name of final output name and path folder
    $folder = FixPath($steps[STEP_WRITECONFIG]['savetofolder']);
    $file = trim($steps[STEP_WRITECONFIG]['maskname']);
    // If deletion was successful
    if (is_file($folder . $file) && unlink($folder . $file)) {
        return true;
    } else {
        return false;
    }
}
Esempio n. 3
0
/**
 *  Read everything in a folder, and recursivly go through all
 *  subfolders to scan for more files. Define the files to include
 *  in the read
 */
function ReadFiles($dir, $filterExt = array())
{
    $files = array();
    $checkFile = "";
    $extension = "";
    // Fix the separators in the path
    $dir = FixPath($dir);
    if (is_dir($dir)) {
        if ($opendir = opendir($dir)) {
            // Read everything in the folder, $checkFile can be both
            // folder, file and for some reason '.' and '..'
            while ($checkFile = readdir($opendir)) {
                // Construct a subfolder variable and if that is
                // valid directory - scan those files first
                $subFolder = FixPath($dir . DIRECTORY_SEPARATOR . $checkFile);
                // If this is a directory - scan that folder
                // first before reading the files in here
                $fromFolder = array();
                if (is_dir($subFolder) && $checkFile != '.' && $checkFile != '..') {
                    $fromFolder = ReadFiles($subFolder, $filterExt);
                }
                // Put all "from folder" files into the $files array
                foreach ($fromFolder as $folderFile) {
                    $files[] = $folderFile;
                }
                // Get file extension
                if (strrpos($checkFile, '.') != false) {
                    $extension = strtolower(substr($checkFile, strrpos($checkFile, '.') + 1));
                } else {
                    $extension = false;
                }
                // If file has extension and either set to delete ALL extensions (empty array)
                // or this extension is in the array of "extensions to delete" - add to
                if ($extension !== false && (count($filterExt) == 0 || in_array($extension, $filterExt))) {
                    // To be sure its a file...
                    if (filetype($dir . '/' . $checkFile) == "file") {
                        $scope = count(explode(DIRECTORY_SEPARATOR, $dir));
                        $files[] = array('scope' => $scope, 'dir' => $dir, 'name' => $checkFile, 'ext' => $extension);
                    }
                }
            }
            closedir($opendir);
        }
    }
    return $files;
}