/**
  * Get name of downloaded MODX directory (e.g., modx-3.4.0-pl).
  *
  * @param $tempDir string - temporary download directory
  * @return string - Name of directory
  */
 public static function getModxDir($tempDir)
 {
     $handle = opendir($tempDir);
     if ($handle !== false) {
         while (false !== ($name = readdir($handle))) {
             if ($name != "." && $name != "..") {
                 $dir = $name;
             }
         }
         closedir($handle);
     } else {
         MODXInstaller::quit('Unable to read directory contents or directory is empty: ' . dirname(__FILE__) . '/temp');
     }
     if (empty($dir)) {
         MODXInstaller::quit('Unknown error reading /temp directory');
     }
     return $dir;
 }
    $modxProcessorsPath = str_replace('\\', '/', $modxProcessorsPath);
    if (strpos(MODX_PROCESSORS_PATH, 'core/model/modx/processors') === false) {
        $directories['core/model/modx/processors'] = $modxProcessorsPath;
    }
    /* Copy directories */
    foreach ($directories as $source => $target) {
        set_time_limit(0);
        MODXInstaller::copyFolder(dirname(__FILE__) . '/temp/' . $dir . '/' . $source, $target);
    }
    MODXInstaller::removeFolder(dirname(__FILE__) . '/temp');
    /* Clear cache files */
    $path = MODX_CORE_PATH . 'cache';
    if (is_dir($path)) {
        MODXInstaller::removeFolder($path);
        /* recreate cache dir */
        MODXInstaller::mmkDir($path);
    }
    unlink(basename(__FILE__));
    header('Location: ' . $rowInstall['location']);
} else {
    $ItemGrid = array();
    foreach ($InstallData as $ver => $item) {
        $ItemGrid[$item['tree']][$ver] = $item;
    }
    /* Display the Form */
    echo '
<!DOCTYPE html>
<html>
<head>
    <title>UpgradeMODX</title>
    <meta charset="utf-8">
Ejemplo n.º 3
0
 public function testRemoveFolder()
 {
     $folder = 'C:\\xampp\\htdocs\\addons\\assets\\mycomponents\\upgrademodx\\_build\\test\\temproot';
     $this->assertTrue(is_dir($folder));
     MODXInstaller::removeFolder($folder, true);
     $this->assertFalse(is_dir($folder));
     $folder = 'C:\\xampp\\htdocs\\addons\\assets\\mycomponents\\upgrademodx\\_build\\test\\temp';
     $this->assertTrue(is_dir($folder));
     MODXInstaller::removeFolder($folder, false);
     $this->assertTrue(is_dir($folder));
     MODXInstaller::removeFolder($folder);
     $this->assertFalse(is_dir($folder));
 }
 public static function quit($msg)
 {
     $begin = '<div style="margin:auto;margin-top:100px;width:40%;height:80px;padding:30px;color:red;border:3px solid darkgray;text-align:center;background-color:rgba(160, 233, 174, 0.42);border-radius:15px;box-shadow: 10px 10px 5px #888888;"><p style="font-size: 14pt;">';
     $end = '</p><p style="margin-bottom:120px;"><a href="' . MODX_MANAGER_URL . '">Back to Manager</a></p></div>';
     MODXInstaller::quit($begin . $msg . $end);
 }