Exemple #1
0
             $postproc->unlink($basepath . 'restoration.php');
             // Import a custom finalisation file
             $filename = dirname(__FILE__) . '/restore_finalisation.php';
             if (file_exists($filename)) {
                 // opcode cache busting before including the filename
                 if (function_exists('opcache_invalidate')) {
                     opcache_invalidate($filename);
                 }
                 if (function_exists('apc_compile_file')) {
                     apc_compile_file($filename);
                 }
                 if (function_exists('wincache_refresh_if_changed')) {
                     wincache_refresh_if_changed(array($filename));
                 }
                 if (function_exists('xcache_asm')) {
                     xcache_asm($filename);
                 }
                 include_once $filename;
             }
             // Run a custom finalisation script
             if (function_exists('finalizeRestore')) {
                 finalizeRestore($root, $basepath);
             }
             break;
         default:
             // Invalid task!
             $enabled = false;
             break;
     }
 }
 // Maybe we weren't authorized or the task was invalid?
Exemple #2
0
    /**
     * Creates the restoration.php file which is used to configure Akeeba Restore (restore.php). Without it, resotre.php
     * is completely inert, preventing abuse.
     *
     * @return  bool
     */
    function createRestorationINI()
    {
        // Get a password
        $this->password = $this->makeRandomPassword(32);
        $this->setState('password', $this->password);
        // Do we have to use FTP?
        $procengine = $this->getState('procengine', 'direct');
        // Get the absolute path to site's root
        $siteroot = JPATH_SITE;
        // Get the JPS password
        $password = addslashes($this->getState('jps_key'));
        $data = "<?php\ndefined('_AKEEBA_RESTORATION') or die();\n";
        $data .= '$restoration_setup = array(' . "\n";
        $data .= <<<ENDDATA
\t'kickstart.security.password' => '{$this->password}',
\t'kickstart.tuning.max_exec_time' => '5',
\t'kickstart.tuning.run_time_bias' => '75',
\t'kickstart.tuning.min_exec_time' => '0',
\t'kickstart.procengine' => '{$procengine}',
\t'kickstart.setup.sourcefile' => '{$this->path}',
\t'kickstart.setup.destdir' => '{$siteroot}',
\t'kickstart.setup.restoreperms' => '0',
\t'kickstart.setup.filetype' => '{$this->extension}',
\t'kickstart.setup.dryrun' => '0',
\t'kickstart.jps.password' => '{$password}'
ENDDATA;
        if ($procengine == 'ftp') {
            $ftp_host = $this->getState('ftp_host', '');
            $ftp_port = $this->getState('ftp_port', '21');
            $ftp_user = $this->getState('ftp_user', '');
            $ftp_pass = addcslashes($this->getState('ftp_pass', ''), "'\\");
            $ftp_root = $this->getState('ftp_root', '');
            $ftp_ssl = $this->getState('ftp_ssl', 0);
            $ftp_pasv = $this->getState('ftp_root', 1);
            $tempdir = $this->getState('tmp_path', '');
            $data .= <<<ENDDATA
\t,
\t'kickstart.ftp.ssl' => '{$ftp_ssl}',
\t'kickstart.ftp.passive' => '{$ftp_pasv}',
\t'kickstart.ftp.host' => '{$ftp_host}',
\t'kickstart.ftp.port' => '{$ftp_port}',
\t'kickstart.ftp.user' => '{$ftp_user}',
\t'kickstart.ftp.pass' => '{$ftp_pass}',
\t'kickstart.ftp.dir' => '{$ftp_root}',
\t'kickstart.ftp.tempdir' => '{$tempdir}'
ENDDATA;
        }
        $data .= ');';
        // Remove the old file, if it's there...
        JLoader::import('joomla.filesystem.file');
        $configpath = JPATH_COMPONENT_ADMINISTRATOR . '/restoration.php';
        clearstatcache(true, $configpath);
        if (@file_exists($configpath)) {
            if (!@unlink($configpath)) {
                JFile::delete($configpath);
            }
        }
        // Write new file
        $result = JFile::write($configpath, $data);
        // Clear opcode caches for the generated .php file
        if (function_exists('opcache_invalidate')) {
            opcache_invalidate($configpath);
        }
        if (function_exists('apc_compile_file')) {
            apc_compile_file($configpath);
        }
        if (function_exists('wincache_refresh_if_changed')) {
            wincache_refresh_if_changed(array($configpath));
        }
        if (function_exists('xcache_asm')) {
            xcache_asm($configpath);
        }
        return $result;
    }