Ejemplo n.º 1
0
 public function upgradePost()
 {
     getAuthentication()->requireAuthentication();
     getUpgrade()->performUpgrade();
     $configObj = getConfig();
     // Backwards compatibility
     // TODO remove in 2.0
     $basePath = dirname(Epi::getPath('config'));
     $configFile = sprintf('%s/userdata/configs/%s.ini', $basePath, getenv('HTTP_HOST'));
     if (!file_exists($configFile)) {
         $configFile = sprintf('%s/generated/%s.ini', Epi::getPath('config'), getenv('HTTP_HOST'));
     }
     $config = $configObj->getString($configFile);
     $config = preg_replace('/lastCodeVersion *= *"\\d+\\.\\d+\\.\\d+"/', sprintf('lastCodeVersion="%s"', getUpgrade()->getCurrentVersion()), $config);
     $configObj->write($configFile, $config);
     $this->route->redirect('/');
 }
Ejemplo n.º 2
0
 public function upgradePost()
 {
     getAuthentication()->requireAuthentication();
     getUpgrade()->performUpgrade();
     $configObj = getConfig();
     // Backwards compatibility
     // TODO remove in 2.0
     $basePath = dirname(Epi::getPath('config'));
     $configFile = sprintf('%s/userdata/configs/%s.ini', $basePath, getenv('HTTP_HOST'));
     if (!file_exists($configFile)) {
         $configFile = sprintf('%s/generated/%s.ini', Epi::getPath('config'), getenv('HTTP_HOST'));
     }
     $config = $configObj->getString($configFile);
     // Backwards compatibility
     // TODO remove in 2.0
     if (strstr($config, 'lastCodeVersion="') !== false) {
         $config = preg_replace('/lastCodeVersion="\\d+\\.\\d+\\.\\d+"/', sprintf('lastCodeVersion="%s"', getUpgrade()->getCurrentVersion()), $config);
     } else {
         // Before the upgrade code the lastCodeVersion was not in the config template
         $config = sprintf("[site]\nlastCodeVersion=\"%s\"\n\n", getUpgrade()->getCurrentVersion()) . $config;
     }
     $configObj->write($configFile, $config);
     $this->route->redirect('/');
 }
Ejemplo n.º 3
0
if (isset($_GET['__route__']) && preg_match('#/user/(.*)(login|logout)#', $_GET['__route__'])) {
    $loginEndpoint = true;
}
if (isset($_GET['__route__']) && preg_match('#^/assets#', $_GET['__route__'])) {
    $assetEndpoint = true;
}
// determine if this is a setup endpoint
$runSetup = false;
if ($hasConfig && isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '/setup') !== false && isset($_GET['edit'])) {
    $runSetup = true;
}
// if the config file exists and we're not running the setup, proceed as normal
if ($hasConfig && !$runSetup) {
    // check if the system needs to upgraded for new code
    $runUpgrade = false;
    if (!getUpgrade()->isCurrent()) {
        $runUpgrade = true;
    }
    require $configObj->get('paths')->libraries . '/routes.php';
    Request::setApiVersion();
    // initializes plugins
    getPlugin()->load();
} else {
    $runUpgrade = false;
    $runSetup = true;
    // setup and enable routes for setup
    $baseDir = dirname(dirname(__FILE__));
    $paths = new stdClass();
    $paths->libraries = "{$baseDir}/libraries";
    $paths->configs = "{$baseDir}/configs";
    $paths->controllers = "{$baseDir}/libraries/controllers";