if (!defined('MODX_CORE_PATH')) { MODXInstaller::quit('Could not read config.core.php'); } @(include MODX_CORE_PATH . 'config/' . MODX_CONFIG_KEY . '.inc.php'); if (!defined('MODX_CONNECTORS_PATH')) { MODXInstaller::quit('Could not read main config file'); } /* run unzip and install */ $source = dirname(__FILE__) . "/modx.zip"; $url = $rowInstall['link']; $certPath = MODX_CORE_PATH . 'components/upgrademodx/cacert.pem'; if (!file_exists($certPath)) { MODXInstaller::quit('Could not find cacert.pem'); } set_time_limit(0); $success = MODXInstaller::downloadFile($url, $source, $method, $certPath); /* Make sure we have the downloaded file */ if ($success !== true) { MODXInstaller::quit($success); } elseif (!file_exists($source)) { MODXInstaller::quit('Missing file: ' . $source); } elseif (filesize($source) < 64) { MODXInstaller::quit('File: ' . $source . ' is empty -- download failed'); } $tempDir = realPath(dirname(__FILE__)) . '/temp'; MODXInstaller::mmkdir($tempDir); clearstatcache(); $destination = $tempDir; if (!file_exists($tempDir)) { MODXInstaller::quit('Unable to create directory: ' . $tempDir); }
// $rowInstall = $InstallData['revo2.3.5-pl']; // Comment our the two lines below to run in debugger. if (!empty($_GET['modx']) && is_scalar($_GET['modx']) && isset($InstallData[$_GET['modx']])) { $rowInstall = $InstallData[$_GET['modx']]; if (file_exists('config.core.php')) { @(include 'config.core.php'); } if (!defined('MODX_CORE_PATH')) { die('Could not read config.core.php'); } @(include MODX_CORE_PATH . 'config/' . MODX_CONFIG_KEY . '.inc.php'); if (!defined('MODX_CONNECTORS_PATH')) { die('Could not read main config file'); } /* run unzip and install */ $success = MODXInstaller::downloadFile($rowInstall['link'], "modx.zip", $method); if ($success !== true) { die($success); } $tempDir = realPath(dirname(__FILE__)) . '/temp'; MODXInstaller::mmkdir($tempDir); clearstatcache(); $source = dirname(__FILE__) . "/modx.zip"; $destination = $tempDir; $success = MODXInstaller::unZip(MODX_CORE_PATH, $source, $destination); if ($success !== true) { die($success); } unlink(dirname(__FILE__) . '/modx.zip'); /* Get name of downloaded MODX directory (e.g., modx-3.4.0-pl). * the MODX files will be below that */
public function testDownloadFileFopen() { $path = dirname(__FILE__) . '/modx.zip'; unlink($path); $url = 'http://modx.com/download/direct/modx-2.4.1-pl.zip'; $method = 'fopen'; MODXInstaller::downloadFile($url, $path, $method); $this->assertFileExists($path); $this->assertNotEmpty(filesize($path)); fwrite(STDOUT, "\n File Size: " . $this->formatSizeUnits(filesize($path))); }
$rowInstall = $InstallData[$_GET['modx']]; if (file_exists('config.core.php')) { @(include 'config.core.php'); } if (!defined('MODX_CORE_PATH')) { MODXInstaller::quit('Could not read config.core.php'); } @(include MODX_CORE_PATH . 'config/' . MODX_CONFIG_KEY . '.inc.php'); if (!defined('MODX_CONNECTORS_PATH')) { MODXInstaller::quit('Could not read main config file'); } /* run unzip and install */ $source = dirname(__FILE__) . "/modx.zip"; $url = $rowInstall['link']; set_time_limit(0); $success = MODXInstaller::downloadFile($url, $source, $method); /* Make sure we have the downloaded file */ if ($success !== true) { MODXInstaller::quit($success); } elseif (!file_exists($source)) { MODXInstaller::quit('Missing file: ' . $source); } elseif (filesize($source) < 1) { MODXInstaller::quit('File: ' . $source . ' is empty -- download failed'); } $tempDir = realPath(dirname(__FILE__)) . '/temp'; MODXInstaller::mmkdir($tempDir); clearstatcache(); $destination = $tempDir; if (!file_exists($tempDir)) { MODXInstaller::quit('Unable to create directory: ' . $tempDir); }